I found a nice zsh command online that uses fzf to fuzzy-search shell history:
fh() {
eval $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//')
}
However, instead of eval-ing the command, I'd like to place it in my prompt and edit it further before running it, something like:
$ fh grep
(search happens)
$ grep -RI foo . <--- cursor
I tried replacing eval with echo, which is better but doesn't give me the command to edit. Is there a way to do this in bash/zsh?
Here is a related thread with a suggestion to use xvkbd, but I was hoping there is something simpler.