aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Jan Meischner <jan.meischner@googlemail.com>2020-07-21 09:57:56 +0200
committerGravatar GitHub <noreply@github.com>2020-07-21 13:27:56 +0530
commit474ad74f256af2c7ab59e0cceea5c5a3877613d9 (patch)
treeafa9cc356ce5d8b48e0259c96283d5ca83329299 /plugins
parentdacf7b08113afd6940bd70681ecb9b41737e3946 (diff)
downloadnnn-474ad74f256af2c7ab59e0cceea5c5a3877613d9.tar.gz
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>
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/fzcd21
1 files changed, 14 insertions, 7 deletions
diff --git a/plugins/fzcd b/plugins/fzcd
index 1925d77..8cc21ab 100755
--- a/plugins/fzcd
+++ b/plugins/fzcd
@@ -20,11 +20,18 @@ if [ -n "$sel" ]; then
exit 0
fi
- # Remove "./" prefix if it exists
- sel="${sel#./}"
- if [ "$PWD" = "/" ]; then
- nnn_cd "/$sel"
- else
- nnn_cd "$PWD/$sel"
- fi
+ # Check if selected path returned
+ # by fzf command is absolute
+ case $sel in
+ /*) nnn_cd "$sel" ;;
+ *)
+ # Remove "./" prefix if it exists
+ sel="${sel#./}"
+
+ if [ "$PWD" = "/" ]; then
+ nnn_cd "/$sel"
+ else
+ nnn_cd "$PWD/$sel"
+ fi;;
+ esac
fi