mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Plugin fzcd - decouple from selection
This commit is contained in:
parent
488fe6b941
commit
d87414eb61
|
@ -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, (fd) |
|
||||||
| [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 |
|
| [fzopen](fzopen) | Fuzzy find file(s) in subtree to edit/open/pick | sh | fzf, xdg-open |
|
||||||
| [fzplug](fzplug) | Fuzzy find, preview and run other plugins | sh | fzf |
|
| [fzplug](fzplug) | Fuzzy find, preview and run other plugins | sh | fzf |
|
||||||
|
|
13
plugins/fzcd
13
plugins/fzcd
|
@ -17,9 +17,6 @@
|
||||||
# - pick the (file)paths in picker mode to path-list file
|
# - pick the (file)paths in picker mode to path-list file
|
||||||
# - OR, edit selection in nnn and save as path-list file
|
# - OR, edit selection in nnn and save as path-list file
|
||||||
#
|
#
|
||||||
# The plugin clears nnn selection as the user can be tempted to delete
|
|
||||||
# duplicate files after finding copies and remove selection by mistake.
|
|
||||||
#
|
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Anna Arad, Arun Prakash Jana
|
# Author: Anna Arad, Arun Prakash Jana
|
||||||
|
|
||||||
|
@ -39,11 +36,6 @@ fi
|
||||||
if [ -n "$1" ] && [ "$(file -b --mime-type "$1")" = 'text/plain' ] && [ -e "$(head -1 "$1")" ]; then
|
if [ -n "$1" ] && [ "$(file -b --mime-type "$1")" = 'text/plain' ] && [ -e "$(head -1 "$1")" ]; then
|
||||||
LIST="$1"
|
LIST="$1"
|
||||||
elif ! [ -s "$LIST" ]; then
|
elif ! [ -s "$LIST" ]; then
|
||||||
# Clear selection
|
|
||||||
if [ -p "$NNN_PIPE" ]; then
|
|
||||||
printf "-" >"$NNN_PIPE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sel=$(fzf)
|
sel=$(fzf)
|
||||||
# Show only the file and parent dir
|
# Show only the file and parent dir
|
||||||
# sel=$(fzf --delimiter / --with-nth=-2,-1 --tiebreak=begin --info=hidden)
|
# sel=$(fzf --delimiter / --with-nth=-2,-1 --tiebreak=begin --info=hidden)
|
||||||
|
@ -63,11 +55,6 @@ if [ -n "$LIST" ]; then
|
||||||
fi
|
fi
|
||||||
done < "$LIST"
|
done < "$LIST"
|
||||||
|
|
||||||
# Clear selection
|
|
||||||
if [ -p "$NNN_PIPE" ]; then
|
|
||||||
printf "-" >"$NNN_PIPE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sel=$(xargs -d '\n' -a "$tmpfile" fd -H . | fzf --delimiter / --tiebreak=begin --info=hidden)
|
sel=$(xargs -d '\n' -a "$tmpfile" fd -H . | fzf --delimiter / --tiebreak=begin --info=hidden)
|
||||||
|
|
||||||
rm "$tmpfile"
|
rm "$tmpfile"
|
||||||
|
|
Loading…
Reference in a new issue