From eb769c0de5d762280b2bd973e3024890c884a58e Mon Sep 17 00:00:00 2001 From: KlzXS Date: Tue, 2 Nov 2021 23:09:47 +0100 Subject: [PATCH] Resolve symlinks one level for .nmv when in list mode --- plugins/.nmv | 6 ++++++ src/nnn.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/plugins/.nmv b/plugins/.nmv index 37b77995..66ca6b3f 100755 --- a/plugins/.nmv +++ b/plugins/.nmv @@ -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") diff --git a/src/nnn.c b/src/nnn.c index 020cba43..2a2627a2 100644 --- 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))