Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

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.

share|improve this answer
add comment

If you have a very long history, could be the cause of the delay. The variables HISTSIZE and HISTFILESIZE are used by bash to set the maximum history size.

Also check the variable HISTIGNORE for ignored (i.e. not put into history) commands. For example I have it set to ignore commands such as ls or exit which i don't need in my history.

To "scroll" search results keep pressing Ctrl-r (backwards) or Ctrl-s (forward). Be careful, though, that Ctrl-s is often used to "lock" the terminal (with Ctrl-Q to unlok), so you may have to remap to something else. You can use something like

stty stop ^G

to map Ctrl-g to terminal lock and free the Ctrl-s shortcut used by bash (to search forward in history).

share|improve this answer
    
stty ixon will make Ctrl-Q available. –  Dennis Williamson Sep 16 '10 at 19:23
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.