bin: update rsync & mount helpers
This commit is contained in:
parent
fed0242e13
commit
be7a4e5732
|
@ -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)
|
||||
|
|
|
@ -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 "$@"
|
|
@ -2,19 +2,26 @@
|
|||
# Mount a partition by label or device identifier automatically
|
||||
test "$1" = "--help" && echo "$0 <device> [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)
|
||||
|
|
Loading…
Reference in New Issue