From 885cfd47345017ca8524c259e53949312360fc8f Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Mon, 9 Dec 2019 18:36:48 +0530 Subject: Support both fzf and fzy --- plugins/fzhist | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'plugins/fzhist') 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 -- cgit v1.2.3-70-g09d2