FollieHiyuki-dotfiles/home/.config/nnn/plugins/fzcd

23 lines
527 B
Plaintext
Raw Normal View History

2021-02-13 11:28:59 -05:00
#!/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
2021-04-03 14:28:33 -04:00
sel=$(fd --type d --follow --hidden --exclude .git | fzf --preview 'exa -1a --sort=type --color always --icons {} 2>/dev/null')
2021-02-13 11:28:59 -05:00
else
exit 1
fi
if [ -n "$sel" ]; then
# Check if selected path returned by fzf command is absolute
case $sel in
/*) nnn_cd "$sel" ;;
*) nnn_cd "$PWD/$sel" ;;
esac
fi