Bash history keys (C-r), (C-s)

Matthias B. matthias at
Sun Dec 4 04:42:26 PST 2005

On Sat, 3 Dec 2005 23:07:40 -0800 (PST) Brandin Creech
<chaotic_thought at> wrote:

>        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.
> However, CTRL+S is the same as "Scroll-lock", or so I thought, so
> pressing "(C-s)" as the manual describes does not work for me. Is there
> a way to perform the (C-s) function that Bash describes, perhaps by
> remapping it to a different key combination?

I assume you're talking about the Linux virtual console, because in xterm
everything works fine for me (but I'm not using default settings, so that
might be responsible).
The Linux vc mappings are in the keymap that is loaded at startup.
My keymap file contains the following

        keycode  31 = +s        +S              ssharp
#protect against accidental sending of XOFF
#scroll lock can still be used for XON/XOFF
#control        keycode  31 = Control_s
control keycode 31 = VoidSymbol

So as you can see in my keymap Ctrl-S is deliberately disabled (mapped to
VoidSymbol), because ^S is XOFF which you don't want to send by accident
(because IIRC it freezes the console until you send XON, which can make
you think your console is broken if it catches you unaware). 

To check if your problem is indeed the Linux console mapping, run 

dumpkeys|grep 31

If you don't see the line

control        keycode  31 = Control_s

then to activate ^S you should be able to put the line

control        keycode  31 = Control_s

into the file you use for KEYMAP_CORRECTIONS (see section 7.6 of the LFS
book). Or you can edit the keymap file you use directly.

Another possible reason for ^S not working aside from it being mismapped
is that the terminal is grabbing it (and interpreting it as XOFF). To
check if that is the case, run

stty -a

If you see

stop = ^S

in the output, then this is your problem. To fix it, put the command

stty stop ^-

into your .bashrc. You will usually want to kill the companion XON, too,
which by default blocks ^Q. Do this with

stty start ^-

ATTENTION! The command "stty sane" resets this! Don't forget this if you
use it to "fix" a "broken" console.


Either start working for a better future
or stop complaining about the bad present.

More information about the blfs-support mailing list