]> Sergey Matveev's repositories - nnn.git/commitdiff
Plugin improvements (#531)
authorKlzXS <azszwymmvqdi@yahoo.com>
Mon, 20 Apr 2020 17:09:30 +0000 (19:09 +0200)
committerGitHub <noreply@github.com>
Mon, 20 Apr 2020 17:09:30 +0000 (22:39 +0530)
* Added padding for numbers in .nmv

* Add skim as an option in fzopen

* Remove unnecessary eval

Thanks @leovilok!

Co-Authored-By: lvgx <l@vgx.fr>
* Added note about whitespace

Co-authored-by: lvgx <l@vgx.fr>
plugins/.nmv
plugins/fzopen

index 01e35da433fdcd05efd526148513236048bf215f..023328df4206952f33eb8069b7b22a4b365cf44c 100755 (executable)
@@ -3,6 +3,8 @@
 # Description: An almost fully POSIX compliant batch file renamer
 #
 # Note: nnn auto-detects and invokes this plugin if available
+#       Whitespace is used as delimiter for read.
+#       The plugin doesn't support filenames with leading or trailing whitespace
 #
 # Capabilities:
 #    1. Basic file rename
@@ -43,7 +45,10 @@ else
        fi
 fi
 
-printf "%s" "$arr" | awk '{print NR " " $0}' > "$dst_file"
+lines=$(printf "%s\n" "$arr" | wc -l)
+width=${#lines}
+
+printf "%s" "$arr" | awk '{printf("%'"${width}"'d %s\n", NR, $0)}' > "$dst_file"
 
 items=("~")
 while IFS='' read -r line; do
index 068db1e912f65d7c1e0555de27ee630e2106949d..9f5ff052f15ba48bc22e56c98c95ccacb1d1d3b0 100755 (executable)
@@ -17,6 +17,8 @@ if which fzf >/dev/null 2>&1; then
     # entry=$(find . -type f 2>/dev/null | fzf --delimiter / --with-nth=-1 --tiebreak=begin --info=hidden)
 elif which fzy >/dev/null 2>&1; then
     entry=$(find . -type f 2>/dev/null | fzy)
+elif which sk >/dev/null 2>&1; then
+       entry=$(find . -type f 2>/dev/null | sk)
 else
     exit 1
 fi