The /etc/inputrc file deals with
mapping the keyboard for specific situations. This file is the
start-up file used by Readline, the
input-related library used by Bash
and most other shells.
For more information, see the bash info page, section Readline Init File. The readline info page is also a good source of information.
Global values are set in /etc/inputrc.
Personal user values are set in ~/.inputrc. The ~/.inputrc file will override the global settings
file. A later page sets up Bash to use /etc/inputrc if there is no .inputrc for a user when /etc/profile is read (usually at login). To make
the system use both, or to negate global keyboard handling, it is a
good idea to place a default .inputrc
into the /etc/skel directory for use
with new users.
Below is a base /etc/inputrc, along
with comments to explain what the various options do. Note that
comments cannot be on the same line as commands.
To create the .inputrc in /etc/skel using the command below, change the
command's output to /etc/skel/.inputrc
and be sure to check/set permissions afterward. Copy that file to
/etc/inputrc and the home directory of
any user already existing on the system, including root, that needs a private version of the
file. Be certain to use the -p parameter of cp to maintain permissions and be
sure to change owner and group appropriately.
cat > /tmp/inputrc.new << "EOF"
# Begin /etc/inputrc
# Modified by Chris Lynn <roryo@roryo.dynup.net>
# Make sure we don't output everything on the 1 line
set horizontal-scroll-mode Off
# Enable 8bit input
set meta-flag On
set input-meta On
# Turns off 8th bit stripping
set convert-meta Off
# Keep the 8th bit for display
set output-meta On
# none, visible or audible
set bell-style none
# All of the following map the escape sequence of the
# value contained inside the 1st argument to the
# readline specific functions
"\eOd": backward-word
"\eOc": forward-word
# for linux console
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
# for xterm
"\eOH": beginning-of-line
"\eOF": end-of-line
# for Konsole
"\e[H": beginning-of-line
"\e[F": end-of-line
# End /etc/inputrc
EOF
install -m644 /tmp/inputrc.new /etc/inputrc
rm /tmp/inputrc.new