The proper way to do this would be to modify hstr to support the fish history file format, but I wanted to try it out a bit before putting the effort in (if I ever get around to it).
The following steps provide a poor man's port by forcing fish to maintain a bash compatible history file (in addition to fish's own history) and pointing hstr to it:
1. Modify your fish prompt to save the bash compatible history file:
~/.config/fish/functions/fish_prompt.fish:
function fish_prompt
.
.
.
echo $history[1] | grep -Ev '(^hh$|^sd|^l.$)' >> ~/.config/fish/hh.history
end
The command as written above filters out the hh command itself, my version of cd, sd, and directory list commands such as ls, ll, lh, etc.
2. Set HISTFILE in config.fish:
~/.config/fish/config.fish:
set -x HISTFILE ~/.config/fish/hh.history
If you want your existing fish history to be available immediately, use Martin's command line love from S08E32:
grep cmd ~/.config/fish/fish_history | cut -d' ' -f3- | sort -u >> ~/.bash_history
Alternatively you could just point HISTFILE to ~/.bash_history.
No comments:
Post a Comment