# Ubuntu – How to forward-search-history with the reverse-i-search command (ctrl+r)

command line

# man readline


The following describes how to search backward and forward.

reverse-search-history (C-r)
Search backward starting at the current line and moving up' through the history as necessary.  This is an incremental search.

forward-search-history (C-s)
Search forward starting at the current line and moving down' through the  history  as  necessary.   This  is  an  incremental search.


When I hit ctrl+r and type "apt-get", I'm able to do a reverse-search-history by continually tapping ctrl+r. But then I tap ctrl+s and the terminal does not go forwards. Am I doing something incorrect?

Also what key does the Meta prefix "M-" represent?

The sequence C-s is taken from the terminal driver, as you can see from

stty -a | grep '\^S'


To free up the sequence for use by readline, set the stop terminal sequence to some other sequence, as for example

stty stop ^J


or remove it altogether with

stty stop undef


After that C-s would work in the given terminal.

Set it in ~/.bashrc to make it work in every terminal.

The M- sequence means the Alt key, as already noted.