Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|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
    
if you go past the command you wanted, do CTRL+SHIFT+R to go back –  Ricky Robinson Mar 7 at 17:18
add comment

2 Answers

up vote 2 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.

share|improve this answer
add comment

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.

share|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 '12 at 19:39
2  
@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 '12 at 22:31
    
thank you, googled for a while and came to the same conclusion, it's mostly useless nowadays –  Gregory Pakosz Feb 3 '12 at 11:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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