Linux – How to Disable Alt-Arrow Switching of Virtual Consoles

consolekeyboard shortcutslinux

The following happens on different Linuces:

When I'm in a virtual console, hold Alt and press or , the virtual ttys cycle. This is really annoying as I'm using fish-shell which also uses this key combo. I could remap fish's short cuts, but I don't want to. Instead I want to disable the linux function or remap it.

How can I disable or change the tty-cycling-key-combo?

Best Answer

You can use the loadkeys command to remap keys on the Linux console. The following lines define the key bindings to switch consoles (on a PC keyboard):

alt keycode 105 = Decr_Console
alt keycode 106 = Incr_Console

Load your own keymap file that overrides these bindings with an escape sequence that fish recognizes. To make a key send an escape sequence, you need to bind it to a key name of the form FNUMBER and define a character sequence for FNUMBER.

alt keycode 105 = F105
alt keycode 106 = F106
string F105 = "\033\033[D"
string F105 = "\033\033[C"

Different distributions (and sometimes different packages for console support) store the system boot-time keymap in different locations under /etc. Look for a file called *.kmap or *.kmap.gz or *.map or *.map.gz under /etc or consult your distribution's manual. Some distributions store a the keymap's name in /etc instead and put the actual keymap elsewhere; look for a keymap-related setting under /etc/sysconfig or other configuration directory.

You can either write your own keymap and use include "/path/to/foo.map" to reference the system keymap, or arrange to load your own keymap containing just the settings you want to change during the boot process.