Resolve symlinks one level for .nmv when in list mode

This commit is contained in:
KlzXS 2021-11-02 23:09:47 +01:00 committed by Arun Prakash Jana
parent b56e488f1c
commit eb769c0de5
No known key found for this signature in database
GPG key ID: A75979F35C080412
2 changed files with 9 additions and 0 deletions

View file

@ -5,6 +5,7 @@
# Note: nnn auto-detects and invokes this plugin if available # Note: nnn auto-detects and invokes this plugin if available
# Whitespace is used as delimiter for read. # Whitespace is used as delimiter for read.
# The plugin doesn't support filenames with leading or trailing whitespace # The plugin doesn't support filenames with leading or trailing whitespace
# To use NNN_LIST your shell must support readlink(1)
# #
# Capabilities: # Capabilities:
# 1. Basic file rename # 1. Basic file rename
@ -21,6 +22,7 @@ TMPDIR="${TMPDIR:-/tmp}"
INCLUDE_HIDDEN="${INCLUDE_HIDDEN:-0}" INCLUDE_HIDDEN="${INCLUDE_HIDDEN:-0}"
VERBOSE="${VERBOSE:-0}" VERBOSE="${VERBOSE:-0}"
RECURSIVE="${RECURSIVE:-0}" RECURSIVE="${RECURSIVE:-0}"
NNN_LIST="${NNN_LIST:-0}"
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
exit_status=0 exit_status=0
@ -61,6 +63,10 @@ printf "%s" "$arr" | awk '{printf("%'"${width}"'d %s\n", NR, $0)}' > "$dst_file"
items=("~") items=("~")
while IFS='' read -r line; do while IFS='' read -r line; do
if [ "$NNN_LIST" -eq 1 ]; then
line=$(readlink "$line" || printf "%s" "$line")
fi
items+=("$line"); items+=("$line");
done < <(printf "%s\n" "$arr") done < <(printf "%s\n" "$arr")

View file

@ -7269,6 +7269,9 @@ nochange:
case SEL_RENAMEMUL: case SEL_RENAMEMUL:
endselection(TRUE); endselection(TRUE);
setenv("INCLUDE_HIDDEN", xitoa(cfg.showhidden), 1); 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]) if (!(getutil(utils[UTIL_BASH])
&& plugscript(utils[UTIL_NMV], F_CLI)) && plugscript(utils[UTIL_NMV], F_CLI))