From da339ad7052a9149b31ddfdb6fb8907f7535b024 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Mon, 7 Aug 2023 17:05:54 +0200 Subject: [PATCH] config/bash: make aliases modular --- .bash_aliases => .config/bash/aliases.bash | 0 .config/bash/iridion.bash | 31 ++++++++++++++++++++++ .config/shell/functions | 6 +++-- .config/yadm/bootstrap | 2 +- 4 files changed, 36 insertions(+), 3 deletions(-) rename .bash_aliases => .config/bash/aliases.bash (100%) create mode 100644 .config/bash/iridion.bash diff --git a/.bash_aliases b/.config/bash/aliases.bash similarity index 100% rename from .bash_aliases rename to .config/bash/aliases.bash diff --git a/.config/bash/iridion.bash b/.config/bash/iridion.bash new file mode 100644 index 0000000..6223861 --- /dev/null +++ b/.config/bash/iridion.bash @@ -0,0 +1,31 @@ +set -o pipefail + +list() { + type="$1" + shift + if test $# -eq 0 && echo $type | grep -q -- '-domains$' + then for user in $(list users) + do test -t 1 && echo "$user" + list "$type" "$user" + done + else if test -t 1 + then sudo "/usr/local/hestia/bin/v-list-$type" "$@" | column -t + else sudo "/usr/local/hestia/bin/v-list-$type" "$@" | tail +3 | awk '{print $1}' + fi + fi +} + +hestia() { + test $# -eq 0 && cd /usr/local/hestia && return 0 + set -x + command=$1 + shift + sudo $(which $command) "$@" + set +x +} + +accessible() { + dir=/home/*/web/$1/public_html + sudo chmod -v 755 $dir + sudo chown -v :sudo $dir +} diff --git a/.config/shell/functions b/.config/shell/functions index 299e417..bdf8bc4 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -263,6 +263,7 @@ curlh() { curl -v --location "$@" >/dev/null } +unalias u 2>/dev/null # for bash u() { # Line below handy for users of netkeeper sudo nft list ruleset | grep -q outall && echo "Suspending netkeeper" >&2 | echo 'pausing netkeeper for sysupgrade' | netkeeper 30 2>/dev/null @@ -331,8 +332,9 @@ sshl() { ! [[ "$1" =~ "delta*" ]] && local pass=pass test "$all" && - $pass scp -O ~/.bash_aliases "$1:" && - $pass ssh "$1" 'grep -q ".bash_aliases" .bashrc || echo "source ~/.bash_aliases" >>.bashrc' + find $XDG_CONFIG_HOME/bash/ \( -name aliases.bash -o -name "$1*.bash" \) -exec cat {} + | $pass ssh "$1" 'cat > .bash_aliases && grep -q .bash_aliases .bashrc || echo "source ~/.bash_aliases" | tee -a .bashrc' && + echo 'Updated .bash_aliases!' + #$pass ssh "$1" 'grep -q ".bash_aliases" .bashrc || echo "source ~/.bash_aliases" >>.bashrc' if test -n "$pass" then pass ssh "$@" else diff --git a/.config/yadm/bootstrap b/.config/yadm/bootstrap index ea4a38e..02c851d 100755 --- a/.config/yadm/bootstrap +++ b/.config/yadm/bootstrap @@ -140,7 +140,7 @@ test "$DISPLAY" || exit 0 highlight "Desktop Applications" subhighlight "Application symlinks" -link .bash_aliases "$HOME/.bashrc" +link "$XDG_CONFIG_HOME/bash/aliases.bash" "$HOME/.bashrc" link "$HOME/.ssh/config" "$XDG_CONFIG_HOME/ssh" link "$XDG_DATA_HOME/.cpan/CPAN/MyConfig.pm" "$XDG_CONFIG_HOME/cpan/MyConfig.pm"