nnn

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 547508aa78ead66a4299423dfef95b24b0895bee
parent d72ab3497aa4a3263900c2a21f9d91a54f3f5d96
Author: Syed Umar Anis <umaranis@users.noreply.github.com>
Date:   Thu,  7 Sep 2023 22:33:01 +1000

fzhist plugin: add support for zsh history #1721 (#1722)

* fzhist plugin: add support for zsh history

* fzhist plugin: check $HISTFILE for history file location

* fzhist plugin: remove extra trailing spaces
Diffstat:
Mplugins/fzhist | 17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/plugins/fzhist b/plugins/fzhist @@ -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 @@ -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"