I use reverse-i-search often, and that's cool. Sometime though when pressing Ctrl+r multiple times, I pass the command I am actually looking for. Because Ctrl+r searches backward in history, from newest to oldest, I have to:

cancel, search again and stop exactly at the command, without passing it. While in reverse-i-search prompt, is it possible to search forward, i.e. from where I stand to newest. I naively tried Ctrl+shift+r, no luck. I heard about Ctrl+g but this is not what I am expecting here. Anyone has an idea?

1 Answer 1


The one-sentence answer: Run stty -ixon in your terminal, and then use Ctrl+S to change the search direction from backward to forward.

The exact answer likely depends on which shell you're using. However, in both bash and Zsh (and probably other shells), you can (in theory) type Ctrl+S to search forward. Thus, after hitting Ctrl+R a few too many times, you can hit Ctrl+S a few times to move to the command you actually want. Many terminals, however, trap Ctrl+S and Ctrl+Q for software flow control, so the Ctrl+S never makes it to bash; if you want bash, rather than your terminal, to read the Ctrl+S, you can disable software flow control by running stty -ixon.

  • I run bash in a gnome3 terminal. Your solution works for me, I can see (reverse-i-search) and (i-search) when toggling Ctrl+s and Ctrl+r. How can I enable software flow control back again? stty -ixon does not seem to prevent reverse search from trapping Ctrl+s
    – m-ric
    Sep 12, 2012 at 14:34
  • 3
    You can reenable software flow control using stty ixon (without the hyphen). Sep 13, 2012 at 13:55
  • 1
    Or just rebind Ctrl+C to Ctrl+X keys with $ stty stop ^X From: ruslanspivak.com/2010/11/20/…
    – A.D.
    Apr 5, 2013 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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