Short Answer
To answer the question directly:
Where is the configuration file for terminal keybindings?
In my case (Ubuntu 16.04 with bash), Serge's answer is useful. (Though I'm not quite sure that it is complete in covering all key bindings that might conflict, which is why I'm writing this longer answer.) Bash configures keybindings in these files:
- default key-bindings:
/etc/inputrc
- custom key-bindings:
~/.inputrc
Long Answer
In this section, I would like to be a bit more comprehensive. While bash and readline affect key bindings, they are other processes involved. For example, how does ALT-2
get bound to TTY #2?
Overview
As an overview, here are the pieces involved on my Ubuntu Server 16.04 machine. I start with systemd, Ubuntu's current init system.
systemd
starts systemd_logind
.
systemd_logind
starts TTY1 with login
.
login
starts bash
.
bash
uses the readline
library.
bash
runs ~/.bashrc
which ultimately starts byobu
byobu
, on my system, uses tmux
as a back-end
(Note: systemd
is used in Ubuntu 15.04 and 16.04. Upstart was the init system for Ubuntu 6.10 to 15.10, according to https://en.wikipedia.org/wiki/Ubuntu_version_history.)
Practically speaking, the following components trap some keypresses:
systemd-logind
(traps ALT-1
, ALT-2
etc).
login
bash
using the readline
library
tmux
byobu
- the TTY (TODO: I don't know if this is a part of
systemd
or login
?)
systemd-logind
For Ubuntu 16.04, systemd-logind is where user logins start. According to the Ubuntu man page for systemd-logind .
systemd-logind is a system service that manages user logins. It is responsible for:
- Keeping track of users and sessions, their processes and their idle state
- Providing PolicyKit-based access for users to operations such as system shutdown or sleep
- Implementing a shutdown/sleep inhibition logic for applications
- Handling of power/sleep hardware keys
- Multi-seat management
- Session switch management
- Device access management for users
- Automatic spawning of text logins (gettys) on virtual console activation and user runtime directory management
See also the man page for logind.conf. I didn't see any mention there of terminal keybindings.
TTY / keyboard configuration
Related links about TTY / keyboard configuration:
Tools for TTY / keyboard layouts:
bash (with the readline library)
The gnu.org bash reference has nice documentation about bash and readline functions.
These configuration files affect key bindings:
- default key-bindings:
/etc/inputrc
- custom key-bindings:
~/.inputrc
tmux
tmux key bindings are described here: https://wiki.archlinux.org/index.php/Tmux#Key_bindings
A user-specific configuration file should be located at ~/.tmux.conf, while a global configuration file should be located at /etc/tmux.conf.
byobu
Byobu has default key bindings which can be user defined in /usr/share/byobu/keybindings/
.
Work In Progress
Note: this answer is a work-in-progress. There may be mistakes. (I find it easier to state what seems to be true based on my reading and reasoning, and correct it if it is wrong.) I will update this and remove this notice when it is closer to completion.
readline
library, whose default key bindings are configured in/etc/inputrc
(overridable by a personal~/.inputrc
). Below that, there'sterminfo
- but that's uncharted waters for me, I'm afraid. Not sure if that's what you're looking for?