(reverse-i-search) in Bash
Solution 1:
There's a similar question on stackoverflow.com.
The best answer there is to use Ctrl+G
to cancel the current search.
Solution 2:
Actually, another answer to that question gives a better option.
In your ~/.bashrc
add the following line:
stty -ixon
Then you can use Ctrl-s to step forward through the history in the same way as you would use Ctrl-r to step backward.
This will even work to start a new forward search (called i-search
as opposed to reverse-i-search
) while browsing through history. Suppose you do Ctrl-r and type some text of a command near your destination then press up arrow several times overshooting what you were really looking for (or you change your mind). Now press Ctrl-s and type a few characters from that line. Zoooom! Straight to it.