nnn

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit eb769c0de5d762280b2bd973e3024890c884a58e
parent b56e488f1c7fc2fd660be8ecf9ed1884efd823a7
Author: KlzXS <klzx+github@klzx.cf>
Date:   Tue,  2 Nov 2021 23:09:47 +0100

Resolve symlinks one level for .nmv when in list mode

Diffstat:
Mplugins/.nmv | 6++++++
Msrc/nnn.c | 3+++
2 files changed, 9 insertions(+), 0 deletions(-)

diff --git 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 @@ -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))