Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In the readline manual

# 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?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

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

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.

share|improve this answer
    
^J is a good choice since for stop, it's not used for anything else –  hobs Apr 2 '13 at 19:56
add comment

forward-search-history (C-s) doesn't work (though it is in the man page).

'M-' represents the Alt key modifier.

share|improve this answer
1  
Not correct the C-s part, see my answer. –  enzotib Sep 5 '11 at 12:45
add comment

Please do not use:

stty stop ^J

but

stty stop ^P

or anything else, as ^J makes big problems with ssh. (I do not know why anyway.) After I logged in Enter and backslash were not working. or I had to type:

stty sane 
export TERM=linux

before I wanted to type

ssh root@192...

so

stty stop ^P

solved both problems at the same time.

share|improve this answer
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.