]> Sergey Matveev's repositories - nnn.git/commitdiff
Allow absolute paths returned by fzf in fzcd plugin (#682)
authorJan Meischner <jan.meischner@googlemail.com>
Tue, 21 Jul 2020 07:57:56 +0000 (09:57 +0200)
committerGitHub <noreply@github.com>
Tue, 21 Jul 2020 07:57:56 +0000 (13:27 +0530)
* 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>
plugins/fzcd

index 1925d776842438694c39d22efd54d24cdbb31fbe..8cc21ab34742d69c753706be9a572d4e738cb5c8 100755 (executable)
@@ -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