summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Touhey <thomas@touhey.fr>2022-04-10 12:42:28 +0200
committerThomas Touhey <thomas@touhey.fr>2022-04-10 12:44:01 +0200
commita29ef14052c06466651a01f90a45264c62656a3b (patch)
tree0c766589265c6d6e5112ea02b225239024368c3d
parent4cc34c4a7b539016c894a7c16f207d050bd0eaf1 (diff)
Path management fixes, switch from *env to asdf, other misc editsHEADmaster
-rw-r--r--.gammurc3
-rw-r--r--.gitconfig2
-rw-r--r--.gitmodules6
m---------.nano0
m---------.oh-my-zsh0
-rwxr-xr-x.paths.bash104
m---------.pyenv0
m---------.rbenv0
-rw-r--r--.ssh/config.d/012_net.cfg7
-rwxr-xr-x.zshenv30
-rwxr-xr-x.zshrc4
11 files changed, 88 insertions, 68 deletions
diff --git a/.gammurc b/.gammurc
index 58e2a70..39f3386 100644
--- a/.gammurc
+++ b/.gammurc
@@ -1,3 +1,4 @@
[gammu]
Connection = at
-Port = /dev/ttyGSM0
+Port = /dev/ttyUSB0
+LogFormat = textalldate
diff --git a/.gitconfig b/.gitconfig
index 701e9af..28dab65 100644
--- a/.gitconfig
+++ b/.gitconfig
@@ -25,3 +25,5 @@
helper = /usr/bin/flynn git-credentials
[pull]
rebase = false
+[init]
+ defaultBranch = main
diff --git a/.gitmodules b/.gitmodules
index 154ca79..03755fc 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -7,9 +7,3 @@
[submodule ".nano"]
path = .nano
url = https://github.com/scopatz/nanorc.git
-[submodule ".pyenv"]
- path = .pyenv
- url = https://github.com/pyenv/pyenv.git
-[submodule ".rbenv"]
- path = .rbenv
- url = https://github.com/rbenv/rbenv.git
diff --git a/.nano b/.nano
-Subproject 6130726c7f09ba6731cfca6f7a7f48e380b2307
+Subproject 1aa64a86cf4c750e4d4788ef1a19d7a71ab641d
diff --git a/.oh-my-zsh b/.oh-my-zsh
-Subproject 9b119866dd0e2d5054abd992f4dfbf346ac81b0
+Subproject 846f417eb8ec76e8eee70000e289b8b81f19d48
diff --git a/.paths.bash b/.paths.bash
index 1de5ff2..304fac3 100755
--- a/.paths.bash
+++ b/.paths.bash
@@ -102,6 +102,15 @@ __thpath_lines() {
{ for (i = 1; i <= NF; i += 2) print $i":"$(i+1) }'
}
+# __thpath_contains(var, path)
+#
+# Check if the given path is already in the raw path or not.
+
+__thpath_contains() {
+ __thpath_lines "$(__thpath_indirect "$1")" | egrep :"$2"$ &>/dev/null
+ return $?
+}
+
# __thpath_sorted_lines()
#
# Same as previous function, but the lines are sorted.
@@ -196,6 +205,14 @@ __thpath_indirect() {
fi
}
+# __thpath_colonful(var)
+#
+# Check if the given string contains colons.
+
+__thpath_colonful() {
+ [[ "$1" == *":"* ]] || return 1
+}
+
# __thpath_check(var)
#
# Check that the variable is managed, call the initialize function
@@ -216,15 +233,52 @@ __thpath_check() {
declare -g "$varname=$(__thpath_produce "$(__thpath_indirect "$ivarname")")"
export "$varname"
fi
+ else
+ # For every element of the given final path, we want to see if it
+ # is already in the raw path; if it is not, we add it in order not
+ # to lose any manual modifications over the raw path.
+
+ __thpath_add_paths "$1" "$(__thpath_indirect "$1")" 50 "y"
fi
}
-# __thpath_colonful(var)
+# __thpath_add_path_internal <varname> <force> <directory> <priority>
#
-# Check if the given string contains colons.
+# Add a directory to a variable using a given priority.
-__thpath_colonful() {
- [[ "$1" == *":"* ]] || return 1
+__thpath_add_path_internal() {
+ local varname="$1"
+ local force="$2"
+ local dr="$3"
+ local pr="$4"
+
+ dr="$(__thpath_realpath -m -s "$dr")"
+ if __thpath_colonful "$dr"; then
+ echo "error: directory name should not contain colon" >&2
+ return 1
+ fi
+
+ [ -z "$pr" ] && pr="50"
+
+ if __thpath_colonful "$pr"; then
+ echo "error: priority should not contain colon" >&2
+ return 1
+ fi
+
+ # Compatibility check: let's see if the directory is a directory,
+ # and if we have access to it.
+
+ if [ x"$force" = x ]; then
+ if [ ! -d "$dr" ]; then
+ return 1
+ fi
+ fi
+
+ # Effectively add the path.
+
+ declare -g "$ivarname=$(__thpath_with "$(__thpath_indirect "$ivarname")" "$dr" "$pr")"
+ declare -g "$varname=$(__thpath_produce "$(__thpath_indirect "$ivarname")")"
+ export "$varname" "$ivarname"
}
# __thpath_add_path <cmd_name> <varname> [-f|--] <directory> <priority>
@@ -268,39 +322,13 @@ __thpath_add_path() {
fi
__thpath_check "$varname"
-
- dr="$(__thpath_realpath -m -s "$dr")"
- if __thpath_colonful "$dr"; then
- echo "error: directory name should not contain colon" >&2
- return 1
- fi
-
- [ -z "$pr" ] && pr="50"
-
- if __thpath_colonful "$pr"; then
- echo "error: priority should not contain colon" >&2
- return 1
- fi
-
- # Compatibility check: let's see if the directory is a directory,
- # and if we have access to it.
-
- if [ x"$force" = x ]; then
- if [ ! -d "$dr" ]; then
- return 1
- fi
- fi
-
- # Effectively add the path.
-
- declare -g "$ivarname=$(__thpath_with "$(__thpath_indirect "$ivarname")" "$dr" "$pr")"
- declare -g "$varname=$(__thpath_produce "$(__thpath_indirect "$ivarname")")"
- export "$varname" "$ivarname"
+ __thpath_add_path_internal "$varname" "$force" "$dr" "$pr"
}
-# __thpath_add_paths(var, directories_colon_joined, priority)
+# __thpath_add_paths(var, directories_colon_joined, priority, if_not_exists)
#
# Add a path to a variable using a given priority.
+# If `if_not_exists` is not none, we want to only add it if it doesn't exist.
__thpath_add_paths() {
local i=''
@@ -311,14 +339,18 @@ __thpath_add_paths() {
# syntax where zsh does.
read -r -d '' dcod <<'EOF'
- for i ($=p); do
- __thpath_add_path "" "$1" -f "$i" "$3"
+ IFS=:; for i ($=p); do
+ if [ "$4" = "" ] || ! __thpath_contains "$1" "$i"; then
+ __thpath_add_path_internal "$1" "y" "$i" "$3"
+ fi
done
EOF
eval $dcod
else
for i in $p; do
- __thpath_add_path "" "$1" -f "$i" "$3"
+ if [ "$4" = "" ] || ! __thpath_contains "$1" "$i"; then
+ __thpath_add_path_internal "$1" "y" "$i" "$3"
+ fi
done
fi
}
diff --git a/.pyenv b/.pyenv
deleted file mode 160000
-Subproject f7450587dcb605f64e9f6085c795c754193ca2a
diff --git a/.rbenv b/.rbenv
deleted file mode 160000
-Subproject 585ed84283f3308380b843391ee7b12706ecff8
diff --git a/.ssh/config.d/012_net.cfg b/.ssh/config.d/012_net.cfg
index e3ab097..025c39a 100644
--- a/.ssh/config.d/012_net.cfg
+++ b/.ssh/config.d/012_net.cfg
@@ -94,3 +94,10 @@ Host artemis artemis.touhey.org
Hostname artemis.touhey.org
IdentityFile ~/.ssh/keys/cake
User cake
+
+Host talma talma.visyerres.org
+ # Vis'Yerres hosting VPS.
+
+ Hostname talma.visyerres.org
+ IdentityFile ~/.ssh/keys/cake
+ User thomas
diff --git a/.zshenv b/.zshenv
index 1389886..b22fda9 100755
--- a/.zshenv
+++ b/.zshenv
@@ -17,16 +17,19 @@ dotfiles() {
}
# Prepare the function to load scripts from a folder.
+#
+# Used to check if files are executable, doesn't anymore
+# because you know, reality.
_load_scripts() {
setopt +o NO_MATCH
for src in "$@"; do
if [ -f "$src" ]; then
- [ -x "$src" ] && source "$src"
+ . "$src"
elif [ -d "$src" ]; then
for p in "$src/"*; do
- [ -x "$p" ] && source "$p"
+ . "$p"
done
fi
done
@@ -76,29 +79,6 @@ fart() {
"$@" &>/dev/null &
}
-# Load ruby using rbenv.
-
-_load_rbenv() {
- if [ -d "$HOME/.rbenv" ]; then
- [ -f "$HOME/.rbenv/src/configure" ] && \
- (cd "$HOME/.rbenv" && src/configure && make --quiet -C src)
- add_path "$HOME/.rbenv/bin"
- fi
-
- eval "$(rbenv init -)"
-}
-
-# Load python using pyenv.
-
-_load_pyenv() {
- if [ -d "$HOME/.pyenv" ]; then
- export PYENV_ROOT="$HOME/.pyenv"
- add_path "$PYENV_ROOT/bin"
- fi
-
- eval "$(pyenv init -)"
-}
-
# ---
# Run scripts.
# ---
diff --git a/.zshrc b/.zshrc
index d3ab51c..a0d127b 100755
--- a/.zshrc
+++ b/.zshrc
@@ -5,6 +5,10 @@
# This file is loaded after the zshenv files.
# Read more: http://zsh.sourceforge.net/Doc/Release/Files.html
#******************************************************************************
+# Run asdf setup if present.
+
+_load_scripts /opt/asdf-vm/asdf.sh
+
# Run the local startup script(s) if any.
# You won't find this file in the git repository, as it is
# more or less unique to each machine and set of needs.