diff --git a/.config/shell/functions b/.config/shell/functions index 07bcccc..bcb3084 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -275,7 +275,10 @@ compdef f=fd lowercase_transliterate="y/A-Z /a-z-/" which perl-rename >/dev/null && alias lowercase="perl-rename '$lowercase_transliterate'" || alias lowercase="rename '$lowercase_transliterate'" -alias move='rsync --recursive --progress --human-readable --remove-source-files' +# rsync directory properly - suffix both dirs with / to act on contents +alias rc='rsync --recursive --specials --info=progress2,remove,symsafe,flist,del --human-readable' +alias dsync='rc ---times --links --delete' +alias move='rc --remove-source-files' alias rdiff='rsync --recursive --progress --delete --links --dry-run' # Swap the names of two files @@ -323,6 +326,12 @@ mkcd() { # Other stuff {{{1 +umoul() { + mountpoint="$(test -d "$1" && realpath "$1" || echo "${XDG_RUNTIME_DIR}/mnt/$1")" + case "$PWD" in ("$mountpoint"*) cd "$(dirname $mountpoint)";; esac + moul -u "$mountpoint" +} + resetdocker() { #aptremove docker-ce kill $(ps -e | grep docker | cut -d' ' -f2) diff --git a/.local/bin/scripts/dsync b/.local/bin/scripts/dsync deleted file mode 100755 index 095564c..0000000 --- a/.local/bin/scripts/dsync +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# rsync directory properly -# suffix both dirs with / to act on contents -rsync -recursive --specials --times --links --delete --info=progress2,remove,symsafe,flist,del --human-readable "$@" diff --git a/.local/bin/scripts/moul b/.local/bin/scripts/moul index 56e69da..47b730c 100755 --- a/.local/bin/scripts/moul +++ b/.local/bin/scripts/moul @@ -2,19 +2,26 @@ # Mount a partition by label or device identifier automatically test "$1" = "--help" && echo "$0 [mountpoint] [options...]" && exit 0 if test "$1" = "-u" -then shift - mountpoint=$(test -d "$1" && echo "$1" || echo "${XDG_RUNTIME_DIR}/mnt/$1") +then + mountpoint="$2" sudo umount "$mountpoint" code=$? sudo rm -d "$mountpoint" exit $? fi -grep -e "[^\w=/]$1[^\w/]" /etc/fstab && mount "$@" && exit 0 +if grep -e "LABEL=$1[^\w/]" /etc/fstab +then mount -L "$@"; exit $? +fi +if grep -e "[^\w=/]$1[^\w/]" /etc/fstab +then mount "$@"; exit $? +fi +mountpoint="${2:-${MNT:-${XDG_RUNTIME_DIR}/mnt}/$1}" +if grep -e "[^\w=/]$mountpoint[^\w/]" /etc/fstab +then shift; mount "$mountpoint" "$@"; code=$?; cd $mountpoint; exit $code +fi case "$1" in - (sd*|loop*|nvme*|mm*|md*|dm*|vg*) partition="/dev/$1" - mountpoint="${2:-${MNT:-${XDG_RUNTIME_DIR}/mnt}/$1}" - grep -e "[^\w=/]$mountpoint[^\w/]" /etc/fstab && shift && mount "$mountpoint" "$@" && exit 0;; + (sd*|loop*|nvme*|mm*|md*|dm*|vg*) partition="/dev/$1";; (*) partition="-L $1";; esac shift $(expr 2 \& $# \> 1 \| 1)