From 1bf49c80e734d7fdefda0686d81f95a1ce619b10 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Tue, 26 Nov 2019 04:36:31 -0800 Subject: Some of the shell script fixes as per discussion (#389) * Improved completion support for files with spaces Filenames with spaces, both generally and for session names, will now complete as expected. * Misc shell script improvements See discussion on: https://github.com/jarun/nnn/commit/1cca9e4b72b106374f203890b266f18609deefe3 --- plugins/fzcd | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'plugins/fzcd') diff --git a/plugins/fzcd b/plugins/fzcd index 3633e64..6ee67d6 100755 --- a/plugins/fzcd +++ b/plugins/fzcd @@ -18,18 +18,17 @@ if [ "$(cmd_exists fzy)" -eq "0" ]; then sel=$($fd | fzy) elif [ "$(cmd_exists fzf)" -eq "0" ]; then - sel=$(fzf --print0) + sel=$(fzf) else exit 1 fi -if ! [ -z "$sel" ]; then - case "$(file -bi "$sel")" in - *directory*) ;; - *) sel=$(dirname "$sel") ;; - esac +if [ -n "$sel" ]; then + if ! [ -d "$sel" ]; then + sel=$(dirname "$sel") + fi - # Remove "./" prefix - sel="$(echo "$sel" | cut -c 3-)" + # Remove "./" prefix if it exists + sel="${sel#./}" nnn_cd "$PWD/$sel" fi -- cgit v1.2.3-70-g09d2