I want to run a function when I start typing in the terminal.
Specifically I want to run the fzf function, for which I currently need to press ctrl-r to trigger it. I would like any keystroke to trigger it so history always appears when I type.
Only the first keystroke should run the function, because running it multiple time toggles between path and filename selection.
I have bound the Up and Down arrow keys to history-search-backward and history-search-forward respectively. So when I type something and then press Up or Down, it does a history search starting with typed letters. This works for me as I don't want to do a history search for every command entered.
I know this isn't exactly what you're looking for, but it's close.
# Bind up and down arrows to do backward and forward history search
if [[ $- == *i* ]]
then
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With