Linux Keymapping for Programs
Applications and keycodes
bash
Bash can be controlled with the inputrc file which is used to set up key control with the bash shell. The "/etc/inputrc" or the ".inputrc" file in the users home directory will set up key codes for bash. My /etc/inputrc file:
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
"\e0d": backward-word
"\e0c": forward-word
"\e[h": beginning-of-line
"\e[f": end-of-line
"\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
This file allows the following flags to be set on or off:
|
|
- bell-style - Possible values are audible (the default), visible, or none. This controls what happens when the Readline function wants to ring the bell.
- comment-begin - The default is #. This defines the string that will be inserted at the start of the line when the insert-comment command if received.
- completion-ignore-case
- completion-query-items
- convert-meta - If on (the default), characters are converted to the ASC seven bit character set.
- disable-completion
- editing mode - May be set to emacs or vi
- enable-keyboard
- expand-tilde
- horizontal-scroll-mode
- input-meta - If set to on, eight bit input is enabled. If off (the default) it only passes seven bits of any character.
- isearch-terminators
- keymap
- mark-directories
- mark-modified-lines
- output-meta
- print-completions-horizontally
- show-all-if-ambiguous
- visible-stats
The following sequences are used to help define keys:
- \C- = Control
- \M- = Meta
- \e = escape character
- \\ = backslach
The below commands can be put in "/etc/inputrc" or "$HOME/.inputrc".
The commands:
set editing-mode emacs
"\e[3~":delete-char
will set the default keybindings to those used by the emacs editor, and bash will recognize the delete key.
The commands:
"\e[1~": beginning-of-line
"\e[3~": delete-char
"\e[4~": end-of-line
will map the <Home>, <Delete>, and <End> keys respectively to the corresponding functions. You can tell which characters are mapped by examining the keycode table.
You may need the following line if your BackSpace key sends the ASCII delete character:
DEL: backward-delete-char
For complete information, read the "Bash Reference Manual" by Chet Ramey, and Brian Fox.
|