nnn/plugins/fzcd
Arun Prakash Jana 4832fc5fe1
Drop fzy support
2020-05-06 18:41:01 +05:30

31 lines
521 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 fzf)" -eq "0" ]; then
sel=$(fzf)
else
exit 1
fi
if [ -n "$sel" ]; then
if ! [ -d "$sel" ]; then
sel=$(dirname "$sel")
elif [ "$sel" = "." ]; then
exit 0
fi
# Remove "./" prefix if it exists
sel="${sel#./}"
if [ "$PWD" = "/" ]; then
nnn_cd "/$sel"
else
nnn_cd "$PWD/$sel"
fi
fi