]> Sergey Matveev's repositories - nnn.git/commitdiff
Resolve symlinks one level for .nmv when in list mode
authorKlzXS <klzx+github@klzx.cf>
Tue, 2 Nov 2021 22:09:47 +0000 (23:09 +0100)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 3 Nov 2021 03:07:08 +0000 (08:37 +0530)
plugins/.nmv
src/nnn.c

index 37b77995bd0bb6408732a885c7701c35d7126fdd..66ca6b3f42a253ee028c527014cfcb7c0bf47336 100755 (executable)
@@ -5,6 +5,7 @@
 # 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
+#       To use NNN_LIST your shell must support readlink(1)
 #
 # Capabilities:
 #    1. Basic file rename
@@ -21,6 +22,7 @@ TMPDIR="${TMPDIR:-/tmp}"
 INCLUDE_HIDDEN="${INCLUDE_HIDDEN:-0}"
 VERBOSE="${VERBOSE:-0}"
 RECURSIVE="${RECURSIVE:-0}"
+NNN_LIST="${NNN_LIST:-0}"
 
 selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
 exit_status=0
@@ -61,6 +63,10 @@ printf "%s" "$arr" | awk '{printf("%'"${width}"'d %s\n", NR, $0)}' > "$dst_file"
 
 items=("~")
 while IFS='' read -r line; do
+       if [ "$NNN_LIST" -eq 1 ]; then
+               line=$(readlink "$line" || printf "%s" "$line")
+       fi
+
        items+=("$line");
 done < <(printf "%s\n" "$arr")
 
index 020cba43e6adc2acb858c79f6b6ada11bd7451f2..2a2627a2fba3abe697fe76dcc400e9efdc58bac9 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -7269,6 +7269,9 @@ nochange:
                        case SEL_RENAMEMUL:
                                endselection(TRUE);
                                setenv("INCLUDE_HIDDEN", xitoa(cfg.showhidden), 1);
+                               setenv("NNN_LIST", listpath
+                                               ? xitoa(is_prefix(path, listpath, xstrlen(listpath)))
+                                               : "0", 1);
 
                                if (!(getutil(utils[UTIL_BASH])
                                      && plugscript(utils[UTIL_NMV], F_CLI))