Merge plugin fzz into autojump

This commit is contained in:
Arun Prakash Jana 2021-07-17 19:47:53 +05:30
parent 1e182a1fe5
commit e31f71285d
No known key found for this signature in database
GPG key ID: A75979F35C080412
3 changed files with 19 additions and 32 deletions

View 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 | | 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 | | [bookmarks](bookmarks) | Use named bookmarks managed with symlinks | sh | fzf |
| [boom](boom) | Play random music from dir | sh | [moc](http://moc.daper.net/) | | [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 | | [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 | | [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 | | [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 | | [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 | | [getplugs](getplugs) | Update plugins to installed `nnn` version | sh | curl |
| [gpg\*](gpg\*) | Encrypt/decrypt files using GPG [✓] | sh | gpg | | [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) | | [gutenread](gutenread) | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional) |

View file

@ -1,16 +1,17 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Description: Navigate to directory using jump/autojump/zoxide # Description: Navigate to directory using jump/autojump/zoxide/z
# #
# Dependencies: # Dependencies:
# - jump - https://github.com/gsamokovarov/jump # - jump - https://github.com/gsamokovarov/jump
# - OR autojump - https://github.com/wting/autojump # - OR autojump - https://github.com/wting/autojump
# - OR zoxide - https://github.com/ajeetdsouza/zoxide # - OR zoxide - https://github.com/ajeetdsouza/zoxide
# - OR z - https://github.com/rupa/z (z requires fzf)
# #
# Note: The dependencies STORE NAVIGATION PATTERNS # Note: The dependencies STORE NAVIGATION PATTERNS
# #
# Shell: POSIX compliant # Shell: POSIX compliant
# Authors: Marty Buchaus, Dave Snider, Tim Adler # Authors: Marty Buchaus, Dave Snider, Tim Adler, Nick Waywood
if [ ! -p "$NNN_PIPE" ]; then if [ ! -p "$NNN_PIPE" ]; then
printf 'ERROR: NNN_PIPE is not set!' 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" printf "%s" "0c$odir" > "$NNN_PIPE"
fi fi
else else
printf "No supported autojump script found. (jump/autojump/zoxide are supported)" 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 _ read -r _
fi fi
fi

View file

@ -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"