Bash – Linux Command Prompt – Ctrl + r – Not working so swell

bashshell

Whenever I hit Ctrl+r in my command prompt it seems like I have 10 milliseconds to finish typing whatever I'm searching for and at that point it searches for whatever I've typed so far.

It also seems to be missing commands I've typed.

Also when I hit escape after such a failed search it puts whatever dumb thing it's found on my command line. How do I get back to empty command line?

Also how do I scroll through the search results?

If this reverse-i-search can't be better, is there a better way to search my history?

Best Answer

The "i" in "reverse-i-search" stands for "incremental" so it searches as you type. If you want it to wait until you finish typing you can use history-search-backward (not bound) or non-incremental-reverse-search-history (bound to Meta-p). To use those functions, you type the text first then press the keystroke that invokes the function.

I have history-search-backward bound to PgUp and ``history-search-forward` bound to PgDn.

To terminate a search press Esc, as you know. To abort a search leaving an empty command line, press Ctrl-G.