Skip to content

Commit

Permalink
fzhist plugin: add support for zsh history #1721 (#1722)
Browse files Browse the repository at this point in the history
* fzhist plugin: add support for zsh history

* fzhist plugin: check $HISTFILE for history file location

* fzhist plugin: remove extra trailing spaces
  • Loading branch information
umaranis committed Sep 7, 2023
1 parent d72ab34 commit 547508a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions plugins/fzhist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# Description: Fuzzy find a command from history,
# edit in $EDITOR and run as a command
#
# Note: Supports only bash and fish history
# Note: Supports only bash, zsh and fish history
#
# TODO: For zsh there's also $ZDOTDIR which might need to be checked as well for the -z $HISTFILE && -n $ZDOTDIR case.
#
# Shell: POSIX compliant
# Author: Arun Prakash Jana
Expand All @@ -17,7 +19,18 @@ fi
shellname="$(basename "$SHELL")"

if [ "$shellname" = "bash" ]; then
hist_file="$HOME/.bash_history"
if [ -f "$HISTFILE" ]; then
hist_file="$HISTFILE"
else
hist_file="$HOME/.bash_history"
fi
entry="$("$fuzzy" < "$hist_file")"
elif [ "$shellname" = "zsh" ]; then
if [ -f "$HISTFILE" ]; then
hist_file="$HISTFILE"
else
hist_file="$HOME/.zsh_history"
fi
entry="$("$fuzzy" < "$hist_file")"
elif [ "$shellname" = "fish" ]; then
hist_file="$HOME/.local/share/fish/fish_history"
Expand Down

0 comments on commit 547508a

Please sign in to comment.