config/shell/functions: add pacman-mirrors and handle parents in umoul

This commit is contained in:
xeruf 2022-01-08 03:00:01 +01:00
parent 25ff6b7546
commit ce516be7ab
1 changed files with 23 additions and 6 deletions

View File

@ -165,7 +165,6 @@ alias jcj='jcl -o json-pretty -u'
# Shorthands # Shorthands
alias v='edit' alias v='edit'
alias u='topgrade --only emacs --yes; topgrade'
alias st='synct' alias st='synct'
alias expr='noglob expr' alias expr='noglob expr'
alias kc='kdeconnect-cli --refresh && kdeconnect-cli --list-devices' alias kc='kdeconnect-cli --refresh && kdeconnect-cli --list-devices'
@ -181,6 +180,14 @@ alias dedup='awk '"'"'!a[$0]++'"'"
alias lar='last | tac' alias lar='last | tac'
alias lst='( last; last -f /var/log/wtmp.1 ) | grep -v "pts/" | tac | less +G' alias lst='( last; last -f /var/log/wtmp.1 ) | grep -v "pts/" | tac | less +G'
u() {
topgrade --only emacs --yes
which pacman-mirrors >/dev/null &&
sudo pacman-mirrors --geoip &&
sudo pacman -Syy
topgrade
}
# Remote # Remote
alias delta="sc restart openvpn-client@deltaPeak.service" alias delta="sc restart openvpn-client@deltaPeak.service"
sshl() { sshl() {
@ -361,11 +368,21 @@ mkcd() {
# Other stuff {{{1 # Other stuff {{{1
umoul() { umoul() {
arg="${1:-$PWD}" if test "$1"
mountpoint="$(test -d "$arg" && realpath "$arg" || echo "${XDG_RUNTIME_DIR}/mnt/$arg")" then arg="$1"
mountpoint "$mountpoint" 2>/dev/null || test -b "$mountpoint" || mountpoint="$(test -d "$arg" && realpath "$arg" || echo "${XDG_RUNTIME_DIR}/mnt/$arg")"
mountpoint="$(mount --show-labels | grep "$arg" | cut -d' ' -f3)" mountpoint "$mountpoint" 2>/dev/null || test -b "$mountpoint" ||
case "$PWD" in ("$mountpoint"*) cd "$(dirname $mountpoint)";; esac mountpoint="$(mount --show-labels | grep "$arg" | cut -d' ' -f3)"
else mountpoint="$PWD"
while test "$mountpoint" != "/"; do
mountpoint "$mountpoint" >/dev/null && break
mountpoint="$(dirname "$mountpoint")"
done
test "$(dirname "$mountpoint")" = "/" && return 1
fi
case "$PWD" in
("$mountpoint"*) cd "$(dirname $mountpoint)";;
esac
moul -u "$mountpoint" moul -u "$mountpoint"
} }