aboutsummaryrefslogtreecommitdiff
path: root/files/.config/nnn/plugins/.nmv
diff options
context:
space:
mode:
Diffstat (limited to 'files/.config/nnn/plugins/.nmv')
-rwxr-xr-xfiles/.config/nnn/plugins/.nmv12
1 files changed, 8 insertions, 4 deletions
diff --git a/files/.config/nnn/plugins/.nmv b/files/.config/nnn/plugins/.nmv
index eaebda6..bc3727f 100755
--- a/files/.config/nnn/plugins/.nmv
+++ b/files/.config/nnn/plugins/.nmv
@@ -31,8 +31,10 @@ case "$NNN_TRASH" in
RM_UTIL="trash-put" ;;
2)
RM_UTIL="gio trash" ;;
+ "")
+ RM_UTIL="rm -ri --" ;;
*)
- RM_UTIL="rm -ri" ;;
+ RM_UTIL="$NNN_TRASH" ;;
esac
exit_status=0
@@ -64,7 +66,7 @@ lines=$(printf "%s\n" "$arr" | wc -l)
width=${#lines}
dst_file=$(mktemp "$TMPDIR/.nnnXXXXXX")
-trap 'rm -f "$dst_file"' EXIT
+trap 'rm -f -- "$dst_file"' EXIT
printf "%s" "$arr" | awk '{printf("%'"${width}"'d %s\n", NR, $0)}' > "$dst_file"
@@ -122,7 +124,7 @@ while read -r num name; do
tmp="$tmp~$c"
done
- if mv "$name" "$tmp"; then
+ if mv -- "$name" "$tmp"; then
if [ "$VERBOSE" -ne 0 ]; then
printf "'%s' -> '%s'\n" "$name" "$tmp"
fi
@@ -133,6 +135,7 @@ while read -r num name; do
for key in "${!items[@]}"; do
if [ "${items[$key]}" = "$name" ]; then
+ # shellcheck disable=2004
items[$key]="$tmp"
fi
done
@@ -142,12 +145,13 @@ while read -r num name; do
if [ ! -d "$dir" ] && ! mkdir -p "$dir"; then
printf "%s: failed to create directory tree %s\n" "$0" "$dir" > /dev/stderr
exit_status=1
- elif ! mv -i "$src" "$name"; then
+ elif ! mv -i -- "$src" "$name"; then
printf "%s: failed to rename %s to %s: %s\n" "$0" "$name" "$tmp" "$!" > /dev/stderr
exit_status=1
else
if [ -d "$name" ]; then
for key in "${!items[@]}"; do
+ # shellcheck disable=2004
items[$key]=$(printf "%s" "${items[$key]}" | sed "s|^$src\(\$\|\/\)|$name\1|")
done