config/bash: make aliases modular

This commit is contained in:
xeruf 2023-08-07 17:05:54 +02:00
parent ae45f56e6e
commit da339ad705
4 changed files with 36 additions and 3 deletions

31
.config/bash/iridion.bash Normal file
View File

@ -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
}

View File

@ -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

View File

@ -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"