]> Sergey Matveev's repositories - nnn.git/commitdiff
Merge plugin fzz into autojump
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 17 Jul 2021 14:17:53 +0000 (19:47 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 17 Jul 2021 14:32:22 +0000 (20:02 +0530)
plugins/README.md
plugins/autojump
plugins/fzz [deleted file]

index e9316fb9eef4ef627cbb8894a8251e2ed3e45307..03a23baa125988df8b1910f9200ccbd25bcb41ae 100644 (file)
@@ -13,7 +13,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
 
 | Plugin (a-z) | Description [Clears selection<sup>1</sup>] | Lang | Dependencies |
 | --- | --- | --- | --- |
-| [autojump](autojump) | Navigate to dir/path | sh | [jump](https://github.com/gsamokovarov/jump)/autojump/zoxide |
+| [autojump](autojump) | Navigate to dir/path | sh | [jump](https://github.com/gsamokovarov/jump)/autojump/<br>zoxide/z (needs fzf) |
 | [bookmarks](bookmarks) | Use named bookmarks managed with symlinks | sh | fzf |
 | [boom](boom) | Play random music from dir | sh | [moc](http://moc.daper.net/) |
 | [bulknew](bulknew) | Create multiple files/dirs at once | bash | sed, xargs, mktemp |
@@ -29,7 +29,6 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
 | [fzhist](fzhist) | Fuzzy-select a cmd from history, edit in `$EDITOR` and run | sh | fzf, mktemp |
 | [fzopen](fzopen) | Fuzzy find file(s) in subtree to edit/open/pick | sh | fzf, xdg-open/open |
 | [fzplug](fzplug) | Fuzzy find, preview and run other plugins | sh | fzf |
-| [fzz](fzz) | Change to any directory in the z database with fzf | sh | fzf, z |
 | [getplugs](getplugs) | Update plugins to installed `nnn` version | sh | curl |
 | [gpg\*](gpg\*) | Encrypt/decrypt files using GPG [✓] | sh | gpg |
 | [gutenread](gutenread) | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional) |
index 19c6548ef71a4b0ecec8878b28537797056a8f6c..5d7bb93b4a9a3989657dcc717a23db3edda9bfe8 100755 (executable)
@@ -1,16 +1,17 @@
 #!/usr/bin/env sh
 
-# Description: Navigate to directory using jump/autojump/zoxide
+# Description: Navigate to directory using jump/autojump/zoxide/z
 #
 # Dependencies:
 #   - jump - https://github.com/gsamokovarov/jump
 #   - OR autojump - https://github.com/wting/autojump
 #   - OR zoxide - https://github.com/ajeetdsouza/zoxide
+#   - OR z - https://github.com/rupa/z (z requires fzf)
 #
 # Note: The dependencies STORE NAVIGATION PATTERNS
 #
 # Shell: POSIX compliant
-# Authors: Marty Buchaus, Dave Snider, Tim Adler
+# Authors: Marty Buchaus, Dave Snider, Tim Adler, Nick Waywood
 
 if [ ! -p "$NNN_PIPE" ]; then
     printf 'ERROR: NNN_PIPE is not set!'
@@ -39,6 +40,19 @@ elif type zoxide >/dev/null 2>&1; then
        printf "%s" "0c$odir" > "$NNN_PIPE"
     fi
 else
-    printf "No supported autojump script found. (jump/autojump/zoxide are supported)"
-    read -r _
+    datafile="${_Z_DATA:-$HOME/.z}"
+    if type fzf >/dev/null 2>&1 && [ -f "$datafile" ]; then
+        # Read the data from z's file instead of calling
+        # z so the data doesn't need to be processed twice
+        sel=$(awk -F "|" '{print $1}' "$datafile" | fzf | awk '{$1=$1};1')
+
+        # NOTE: Uncomment this line and comment out the line above if
+        # you want to see the weightings of the dir's in the fzf pane
+        # sel=$(awk -F "|" '{printf "%s %s\n", $2, $1}' "$datafile" | fzf | sed 's/^[0-9,.]* *//' | awk '{$1=$1};1')
+
+        printf "%s" "0c$sel" > "$NNN_PIPE"
+    else
+        printf "No supported autojump script [jump/autojump/zoxide/z (needs fzf)] found"
+        read -r _
+    fi
 fi
diff --git a/plugins/fzz b/plugins/fzz
deleted file mode 100755 (executable)
index a79cee0..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env sh
-
-# Description: cd to any dir in the z database using an fzf pane
-#
-# Shell: POSIX compliant
-# Author: Nick Waywood
-
-. "$(dirname "$0")"/.nnn-plugin-helper
-
-if type fzf >/dev/null 2>&1; then
-    fuzzy=fzf
-else
-    exit 1
-fi
-
-datafile="${_Z_DATA:-$HOME/.z}"
-if [ -f "$datafile" ]; then
-    # I read the data from z's file instead of calling the z command so that the data doesn't need to be processed twice
-    sel=$(awk -F "|" '{print $1}' "$datafile" | "$fuzzy" | awk '{$1=$1};1')
-    # NOTE: Uncomment this line and comment out the line above if you want to see the weightings of the dir's in the fzf pane
-    # sel=$(awk -F "|" '{printf "%s %s\n", $2, $1}' "$datafile" | "$fuzzy" | sed 's/^[0-9,.]* *//' | awk '{$1=$1};1')
-else
-    exit 1
-fi
-
-printf "%s" "0c$sel" > "$NNN_PIPE"