aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/fzopen
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-09 18:36:48 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-09 18:36:48 +0530
commit885cfd47345017ca8524c259e53949312360fc8f (patch)
tree367464beb26ff93da9e5c48c231159122ba88dbb /plugins/fzopen
parent9614fec13ba9b1363d5845f862384ed4018f2d4b (diff)
downloadnnn-885cfd47345017ca8524c259e53949312360fc8f.tar.gz
Support both fzf and fzy
Diffstat (limited to 'plugins/fzopen')
-rwxr-xr-xplugins/fzopen12
1 files changed, 11 insertions, 1 deletions
diff --git a/plugins/fzopen b/plugins/fzopen
index 046e7e9..91a504d 100755
--- a/plugins/fzopen
+++ b/plugins/fzopen
@@ -4,10 +4,20 @@
# Opens in $VISUAL or $EDITOR if text
# Opens other type of files with xdg-open
#
+# Requires: fzf/fzy, xdg-open
+#
# Shell: POSIX compliant
# Author: Arun Prakash Jana
-entry="$(find . -type f 2>/dev/null | fzy)"
+if which fzf >/dev/null 2>&1; then
+ fuzzy=fzf
+elif which fzy >/dev/null 2>&1; then
+ fuzzy=fzy
+else
+ exit 1
+fi
+
+entry="$(find . -type f 2>/dev/null | "$fuzzy")"
case "$(file -biL "$entry")" in
*text*)