4 Answers
4

To search backward in the history for a particular string, type C-r.
Typing C-s searches forward through the history.

The problem with Ctrl-S however is that sometimes collides with XON/XOFF flow control (in Konsole for instance). The searching is a readline feature however, and you should be able to bind it to some other key. Update: Simpler and better is just to disable XON/XOFF by running

This is brilliant, but I add stty -ixon to my .profile and it doesn't seem to work for new tabs. Any ideas on how to make this work? I'd love XON/XOFF to be disabled by default.
– John GallagherSep 20 '11 at 9:10

10

In case anyone else has the same issue I did - if you add this to .profile it doesn't take effect. It's only when you add it to the .bash_profile that the magic happens! Thanks for a great tip - this had been driving me mad for years.
– John GallagherSep 20 '11 at 9:24

9

@JohnGallagher Important to note is that .bash_profile and .profile are only sourced for log-in shells. I would put this in .bashrc (which I source from .profile).
– Victor ZamanianJan 26 '12 at 11:51

9

[[ $- == *i* ]] && stty -ixon can be used to avoid the problem described here
– mMontuAug 19 '14 at 19:53

2

In case you're using PuTTY and can't/don't want to maintain .bash_profile on every machine you connect to, this answer on superuser works a treat.
– fazyOct 8 '14 at 15:44

You may want to try https://github.com/dvorka/hstr which allows for "suggest box style" filtering of Bash history with (optional) metrics based ordering i.e. it is much more efficient and faster in both forward and backward directions: