aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Nick Waywood <nwaywood@au1.ibm.com>2020-04-02 16:24:24 +1100
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-04-02 10:58:54 +0530
commit415a6edd4a553d2ecf3b2b26b79ab844473127a3 (patch)
treef0b81dfe2db23ef0f67ca912248e63788943e665 /plugins
parent553f183919e2326f485eb2cc16309c60b0c3b7a7 (diff)
downloadnnn-415a6edd4a553d2ecf3b2b26b79ab844473127a3.tar.gz
Added support for fzy (#505)
* Added fzfz plugin * Fixed shellcheck errors * Fixed copy/paste error * Added support for fzy, also renamed plugin since it's not specific to fzf anymore * Refactored code * Clean spillovers (jarun)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/README.md2
-rwxr-xr-xplugins/fzfz23
-rwxr-xr-xplugins/fzz27
3 files changed, 28 insertions, 24 deletions
diff --git a/plugins/README.md b/plugins/README.md
index 156e786..f46b8ce 100644
--- a/plugins/README.md
+++ b/plugins/README.md
@@ -33,9 +33,9 @@ Plugins are installed to `${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins`.
| diffs | Diff for selection (limited to 2 for directories) | sh | vimdiff |
| dragdrop | Drag/drop files from/into nnn | sh | [dragon](https://github.com/mwh/dragon) |
| fzcd | Change to the directory of a fuzzy-selected file/dir | sh | fzf/fzy<br>fd/fdfind/find |
-| fzfz | Change to any directory in the z database with fzf | sh | fzf, z |
| fzhist | Fuzzy-select a cmd from history, edit in `$EDITOR` and run | sh | fzf/fzy |
| fzopen | Fuzzy find a file in dir subtree and edit or open | sh | fzf/fzy, xdg-open |
+| fzz | Change to any directory in the z database with fzf/fzy | sh | fzf/fzy, z |
| getplugs | Update plugins | sh | curl |
| gutenread | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional) |
| hexview | View a file in hex in `$PAGER` | sh | xxd |
diff --git a/plugins/fzfz b/plugins/fzfz
deleted file mode 100755
index cb5e08a..0000000
--- a/plugins/fzfz
+++ /dev/null
@@ -1,23 +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 [ "$(cmd_exists fzf)" -eq "0" ]; then
- if [ -f "$HOME/.z" ]; 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}' "$HOME/.z" | 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}' "$HOME/.z" | fzf | sed 's/^[0-9,.]* *//' | awk '{$1=$1};1')
- else
- exit 1
- fi
-else
- exit 1
-fi
-
-printf "%s" "0$sel" > "$NNN_PIPE"
diff --git a/plugins/fzz b/plugins/fzz
new file mode 100755
index 0000000..f84a064
--- /dev/null
+++ b/plugins/fzz
@@ -0,0 +1,27 @@
+#!/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 which fzf >/dev/null 2>&1; then
+ fuzzy=fzf
+elif which fzy >/dev/null 2>&1; then
+ fuzzy=fzy
+else
+ exit 1
+fi
+
+if [ -f "$HOME/.z" ]; 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}' "$HOME/.z" | "$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/fzy pane
+ # sel=$(awk -F "|" '{printf "%s %s\n", $2, $1}' "$HOME/.z" | "$fuzzy" | sed 's/^[0-9,.]* *//' | awk '{$1=$1};1')
+else
+ exit 1
+fi
+
+printf "%s" "0$sel" > "$NNN_PIPE"