In my .bash_profile
, I've bound the up/down arrow keys to the history-search functions:
if [[ $- == *i* ]]
then
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
fi
This allows me to search my history backwards using the up arrow and forwards using the down one. However, if I'm searching forwards and I get to the last command, I want to be able to press down again to remove the search result at the cursor. For example, if |
is the cursor:
$ echo hello|
hello
$ echo |
Pressing the up arrow key here will do:
$ echo hello|
hello
$ echo |hello
I would like to be able to press the down arrow key to remove the hello
(i.e the search result) so that I'm back at:
$ echo hello|
hello
$ echo |
Apologies if this has been asked before, I couldn't find an answer myself.