I usually end up using CTRL+r for (reverse-i-search), however, sometimes I pass the command that I was looking for; if I do again a (reverse-i-search) it doesn't find it anymore. I assume that the current pointer to the command history is before the command I'm looking for.

Does anybody knows how to go back to the most current command in the history without having to click 1000 times the down arrow?

Thanks

link|improve this question
The reverse search is a feature of bash (and the readline libaries), so I've edited the title and question a little to reflect that. – Doug Harris Jul 1 '10 at 19:56
feedback

2 Answers

up vote 0 down vote accepted

There's a similar question on stackoverflow.com.

The best answer there is to use Ctrl+G to cancel the current search.

link|improve this answer
feedback

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.

link|improve this answer
what's the implication of stty -ixon? does it disable something that might be needed in other situations? – Gregory Pakosz Feb 1 at 19:39
@GregoryPakosz: It disables XON/XOFF (software flow control), which is useless from the keyboard now that we're communicating at a little bit higher rate than 300 baud. – Dennis Williamson Feb 1 at 22:31
thank you, googled for a while and came to the same conclusion, it's mostly useless nowadays – Gregory Pakosz Feb 3 at 11:18
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.