aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/fzhist
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/fzhist
parent9614fec13ba9b1363d5845f862384ed4018f2d4b (diff)
downloadnnn-885cfd47345017ca8524c259e53949312360fc8f.tar.gz
Support both fzf and fzy
Diffstat (limited to 'plugins/fzhist')
-rwxr-xr-xplugins/fzhist12
1 files changed, 10 insertions, 2 deletions
diff --git a/plugins/fzhist b/plugins/fzhist
index c47efa2..e5618ae 100755
--- a/plugins/fzhist
+++ b/plugins/fzhist
@@ -6,14 +6,22 @@
# Shell: POSIX compliant
# Author: Arun Prakash Jana
+if which fzf >/dev/null 2>&1; then
+ fuzzy=fzf
+elif which fzy >/dev/null 2>&1; then
+ fuzzy=fzy
+else
+ exit 1
+fi
+
shellname="$(basename "$SHELL")"
if [ "$shellname" = "bash" ]; then
hist_file="$HOME/.bash_history"
- entry="$(fzy < "$hist_file")"
+ entry="$("$fuzzy" < "$hist_file")"
elif [ "$shellname" = "fish" ]; then
hist_file="$HOME/.config/fish/fish_history"
- entry="$(grep "\- cmd: " "$hist_file" | cut -c 8- | fzy)"
+ entry="$(grep "\- cmd: " "$hist_file" | cut -c 8- | "$fuzzy")"
fi
if ! [ -z "$entry" ]; then