aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar KlzXS <azszwymmvqdi@yahoo.com>2020-03-20 20:28:42 +0100
committerGravatar GitHub <noreply@github.com>2020-03-21 00:58:42 +0530
commitaab90bf515f30bbd71bf034fb27813b84818c2c6 (patch)
tree631fd3b79815d07a1aafb51111aa35d9606e048a
parent5e8f0aec35716453853f568ff9c75bba869c1150 (diff)
downloadnnn-aab90bf515f30bbd71bf034fb27813b84818c2c6.tar.gz
Add verbose option (#497)
-rwxr-xr-xplugins/.nmv14
1 files changed, 11 insertions, 3 deletions
diff --git a/plugins/.nmv b/plugins/.nmv
index b89842f..01e35da 100755
--- a/plugins/.nmv
+++ b/plugins/.nmv
@@ -17,6 +17,7 @@
EDITOR="${EDITOR:-vi}"
TMPDIR="${TMPDIR:-/tmp}"
INCLUDE_HIDDEN="${INCLUDE_HIDDEN:-0}"
+VERBOSE="${VERBOSE:-0}"
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
exit_status=0
@@ -95,7 +96,9 @@ while read -r num name; do
done
if mv "$name" "$tmp"; then
- printf "'%s' -> '%s'\n" "$name" "$tmp"
+ if [ "$VERBOSE" -ne 0 ]; then
+ printf "'%s' -> '%s'\n" "$name" "$tmp"
+ fi
else
printf "%s: failed to rename %s to %s: %s\n" "$0" "$name" "$tmp" "$!" > /dev/stderr
exit_status=1
@@ -121,9 +124,14 @@ while read -r num name; do
items[$key]=$(printf "%s" "${items[$key]}" | sed "s|^$src\(\$\|\/\)|$name\1|")
done
- printf "'%s' => '%s'\n" "$src" "$name"
+ if [ "$VERBOSE" -ne 0 ]; then
+ printf "'%s' => '%s'\n" "$src" "$name"
+ fi
else
- printf "'%s' -> '%s'\n" "$src" "$name"
+ true
+ if [ "$VERBOSE" -ne 0 ]; then
+ printf "'%s' -> '%s'\n" "$src" "$name"
+ fi
fi
fi
fi