Allow absolute paths returned by fzf in fzcd plugin (#682)

* Allow absolute paths returned by fzf in fzcd plugin

* Fix issue with POSIX syntax

* Add descriptive comment

* Add comment

* Remove description

* Add new line at the end of the file

Co-authored-by: Jan Meischner <jan.meischner@verimi.com>
This commit is contained in:
Jan Meischner 2020-07-21 09:57:56 +02:00 committed by GitHub
parent dacf7b0811
commit 474ad74f25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,11 +20,18 @@ if [ -n "$sel" ]; then
exit 0 exit 0
fi fi
# Check if selected path returned
# by fzf command is absolute
case $sel in
/*) nnn_cd "$sel" ;;
*)
# Remove "./" prefix if it exists # Remove "./" prefix if it exists
sel="${sel#./}" sel="${sel#./}"
if [ "$PWD" = "/" ]; then if [ "$PWD" = "/" ]; then
nnn_cd "/$sel" nnn_cd "/$sel"
else else
nnn_cd "$PWD/$sel" nnn_cd "$PWD/$sel"
fi fi;;
esac
fi fi