mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
5b7448bac9
1. getplugs should work even if nnn is not run 2. Remove redundant ./ prefix 3. Update plugin docs
36 lines
636 B
Bash
Executable file
36 lines
636 B
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
# Description: Run fzf and go to the directory of the file selected
|
|
#
|
|
# Shell: POSIX compliant
|
|
# Author: Anna Arad
|
|
|
|
. $(dirname $0)/.nnn-plugin-helper
|
|
|
|
if [ "$(cmd_exists fzy)" -eq "0" ]; then
|
|
if [ "$(cmd_exists fd)" -eq "0" ]; then
|
|
fd=fd
|
|
elif [ "$(cmd_exists fdfind)" -eq "0" ]; then
|
|
fd=fdfind
|
|
else
|
|
fd=find
|
|
fi
|
|
|
|
sel=$($fd | fzy)
|
|
elif [ "$(cmd_exists fzf)" -eq "0" ]; then
|
|
sel=$(fzf --print0)
|
|
else
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$?" -eq "0" ]; then
|
|
case "$(file -bi "$sel")" in
|
|
*directory*) ;;
|
|
*) sel=$(dirname "$sel") ;;
|
|
esac
|
|
|
|
# Remove "./" prefix
|
|
sel="$(echo "$sel" | cut -c 3-)"
|
|
nnn_cd "$PWD/$sel"
|
|
fi
|