diff --git a/plugins/README.md b/plugins/README.md index e9316fb9..03a23baa 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -13,7 +13,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina | Plugin (a-z) | Description [Clears selection1] | 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/
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
[epr](https://github.com/wustho/epr) (optional) | diff --git a/plugins/autojump b/plugins/autojump index 19c6548e..5d7bb93b 100755 --- a/plugins/autojump +++ b/plugins/autojump @@ -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 index a79cee0a..00000000 --- a/plugins/fzz +++ /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"