mirror of
https://github.com/jarun/nnn.git
synced 2024-11-27 21:31:30 +00:00
Replace fd dependency with find (#1078)
This commit is contained in:
parent
7ce5bbcdf7
commit
20e0c49292
|
@ -25,7 +25,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
|
||||||
| [dups](dups) | List non-empty duplicate files in current dir | bash | find, md5sum,<br>sort uniq xargs |
|
| [dups](dups) | List non-empty duplicate files in current dir | bash | find, md5sum,<br>sort uniq xargs |
|
||||||
| [finder](finder) | Run custom find command and list | sh | - |
|
| [finder](finder) | Run custom find command and list | sh | - |
|
||||||
| [fixname](fixname) | Clean filename to be more shell-friendly [✓] | bash | sed |
|
| [fixname](fixname) | Clean filename to be more shell-friendly [✓] | bash | sed |
|
||||||
| [fzcd](fzcd) | Fuzzy search multiple dirs (or `$PWD`) and visit file | sh | fzf, (fd) |
|
| [fzcd](fzcd) | Fuzzy search multiple dirs (or `$PWD`) and visit file | sh | fzf, (find) |
|
||||||
| [fzhist](fzhist) | Fuzzy-select a cmd from history, edit in `$EDITOR` and run | sh | fzf, mktemp |
|
| [fzhist](fzhist) | Fuzzy-select a cmd from history, edit in `$EDITOR` and run | sh | fzf, mktemp |
|
||||||
| [fzopen](fzopen) | Fuzzy find file(s) in subtree to edit/open/pick | sh | fzf, xdg-open/open |
|
| [fzopen](fzopen) | Fuzzy find file(s) in subtree to edit/open/pick | sh | fzf, xdg-open/open |
|
||||||
| [fzplug](fzplug) | Fuzzy find, preview and run other plugins | sh | fzf |
|
| [fzplug](fzplug) | Fuzzy find, preview and run other plugins | sh | fzf |
|
||||||
|
|
12
plugins/fzcd
12
plugins/fzcd
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Description: Fuzzy search multiple locations read-in from a path-list file
|
# Description: Fuzzy search multiple locations read-in from a path-list file
|
||||||
# (or $PWD) and open the selected file's dir in a smart context.
|
# (or $PWD) and open the selected file's dir in a smart context.
|
||||||
# Dependencies: fzf, fd (only for multi-location search)
|
# Dependencies: fzf, find (only for multi-location search)
|
||||||
#
|
#
|
||||||
# Details: Paths in list file should be newline-separated absolute paths.
|
# Details: Paths in list file should be newline-separated absolute paths.
|
||||||
# Paths can be file paths; the script will scan the parent dirs.
|
# Paths can be file paths; the script will scan the parent dirs.
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
# - OR, edit selection in nnn and save as path-list file
|
# - OR, edit selection in nnn and save as path-list file
|
||||||
#
|
#
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Anna Arad, Arun Prakash Jana
|
# Author: Anna Arad, Arun Prakash Jana, KlzXS
|
||||||
|
|
||||||
IFS="$(printf '\n\r')"
|
IFS="$(printf '\n\r')"
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ elif ! [ -s "$LIST" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$LIST" ]; then
|
if [ -n "$LIST" ]; then
|
||||||
if type fd >/dev/null 2>&1; then
|
if type find >/dev/null 2>&1; then
|
||||||
tmpfile=$(mktemp /tmp/abc-script.XXXXXX)
|
tmpfile=$(mktemp /tmp/abc-script.XXXXXX)
|
||||||
|
|
||||||
while IFS= read -r path; do
|
while IFS= read -r path; do
|
||||||
|
@ -55,11 +55,13 @@ if [ -n "$LIST" ]; then
|
||||||
fi
|
fi
|
||||||
done < "$LIST"
|
done < "$LIST"
|
||||||
|
|
||||||
sel=$(xargs -d '\n' -a "$tmpfile" fd -H . | fzf --delimiter / --tiebreak=begin --info=hidden)
|
sel=$(xargs -d '\n' -a "$tmpfile" -I{} find {} -type f -printf "%H//%P\n" | sed '/.*\/\/\(\..*\|.*\/\..*\)/d; s:/\+:/:g' | fzf --delimiter / --tiebreak=begin --info=hidden)
|
||||||
|
# Alternative for 'fd'
|
||||||
|
# sel=$(xargs -d '\n' -a "$tmpfile" fd . | fzf --delimiter / --tiebreak=begin --info=hidden)
|
||||||
|
|
||||||
rm "$tmpfile"
|
rm "$tmpfile"
|
||||||
else
|
else
|
||||||
printf "fd missing"
|
printf "find missing"
|
||||||
read -r _
|
read -r _
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue