summaryrefslogtreecommitdiff
path: root/.config/bash/rc.d
diff options
context:
space:
mode:
Diffstat (limited to '.config/bash/rc.d')
-rw-r--r--.config/bash/rc.d/10_aliases.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/.config/bash/rc.d/10_aliases.sh b/.config/bash/rc.d/10_aliases.sh
index d6a1ab3..f34230b 100644
--- a/.config/bash/rc.d/10_aliases.sh
+++ b/.config/bash/rc.d/10_aliases.sh
@@ -82,15 +82,23 @@ term-title() {
printf "$fmt" "$*"
}
mvln() {
+ local target link
if [[ ! -L "$1" ]]; then
libremessages error 'Not a soft link: %s' "$1"
+ return 1
fi
- target=$(readlink -f -- "$1")
- ln -srT -- "$target" "$2"
- if cmp -- "$1" "$2"; then
+ if [[ -d "$2" ]]; then
+ link="$2/${1##*/}"
+ else
+ link="$2"
+ fi
+ target=$(readlink -f -- "$1") || return 1
+ ln -srT -- "$target" "$link"
+ if cmp -- "$1" "$link"; then
rm -f -- "$1"
else
- libremessages error 'Failed moving link: %s -> %s' "$1" "$2"
+ libremessages error 'Failed moving link: %s -> %s' "$1" "$link"
+ return 1
fi
}
jarls() {