aboutsummaryrefslogtreecommitdiff
path: root/files/.config/nnn/plugins/fzhist
diff options
context:
space:
mode:
authorAnton Bobov <anton@bobov.name>2026-08-20 15:13:47 +0500
committerAnton Bobov <anton@bobov.name>2026-08-20 15:13:47 +0500
commit153c9344e93662984b1a5368a2722c10117db830 (patch)
tree46b44af16387c815ab6c783415ee7dc1b8287a5c /files/.config/nnn/plugins/fzhist
parentccbc3e18f711c39482e9ed6045ed99b4da889a59 (diff)
nnn: update plugins
Diffstat (limited to 'files/.config/nnn/plugins/fzhist')
-rwxr-xr-xfiles/.config/nnn/plugins/fzhist19
1 files changed, 16 insertions, 3 deletions
diff --git a/files/.config/nnn/plugins/fzhist b/files/.config/nnn/plugins/fzhist
index 111bc22..de10c2a 100755
--- a/files/.config/nnn/plugins/fzhist
+++ b/files/.config/nnn/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"
@@ -33,7 +46,7 @@ if [ -n "$entry" ]; then
$SHELL -c "$(cat "$tmpfile")"
fi
- rm "$tmpfile"
+ rm -- "$tmpfile"
printf "Press any key to exit"
read -r _