There are only a few basic constructs allowed in the Readline init file. Blank lines are ignored. Lines beginning with a # are comments. Lines beginning with a $ indicate conditional constructs (see Conditional Init Constructs). Other lines denote variable settings and key bindings.
set
command within the init file. Here is how to
change from the default Emacs-like key binding to use
vi
line editing commands:
set editing-mode vi
A great deal of run-time behavior is changeable with the following variables.
bell-style
comment-begin
insert-comment
command is executed. The default value
is "#"
.
completion-ignore-case
completion-query-items
100
.
convert-meta
disable-completion
self-insert
. The default is off.
editing-mode
editing-mode
variable controls which default set of
key bindings is used. By default, Readline starts up in Emacs editing
mode, where the keystrokes are most similar to Emacs. This variable can be
set to either emacs or vi.
enable-keypad
expand-tilde
horizontal-scroll-mode
input-meta
meta-flag
is a
synonym for this variable.
isearch-terminators
keymap
keymap
names are
emacs
,
emacs-standard
,
emacs-meta
,
emacs-ctlx
,
vi
,
vi-command
, and
vi-insert
.
vi
is equivalent to vi-command
; emacs
is
equivalent to emacs-standard
. The default value is emacs
.
The value of the editing-mode
variable also affects the
default keymap.
mark-directories
mark-modified-lines
output-meta
print-completions-horizontally
show-all-if-ambiguous
visible-stats
Once you know the name of the command, simply place the name of the key you wish to bind the command to, a colon, and then the name of the command on a line in the init file. The name of the key can be expressed in different ways, depending on which is most comfortable for you.
Control-u: universal-argument Meta-Rubout: backward-kill-word Control-o: "> output"
In the above example, <C-u> is bound to the function
universal-argument
, and <C-o> is bound to run the macro
expressed on the right hand side (that is, to insert the text
> output into the line).
"\C-u": universal-argument "\C-x\C-r": re-read-init-file "\e[11~": "Function Key 1"
In the above example, <C-u> is bound to the function
universal-argument
(just as it was in the first example),
<C-x> <C-r> is bound to the function re-read-init-file
,
and <ESC> <[> <1> <1> <~> is bound to insert
the text Function Key 1.
The following gnu Emacs style escape sequences are available when specifying key sequences:
In addition to the gnu Emacs style escape sequences, a second set of backslash escapes is available:
\a
\b
\d
\f
\n
\r
\t
\v
\
nnnASCII
code is the octal value nnn
(one to three digits)
\x
nnnASCII
code is the hexadecimal value nnn
(one to three digits)
When entering the text of a macro, single or double quotes must be used to indicate a macro definition. Unquoted text is assumed to be a function name. In the macro body, the backslash escapes described above are expanded. Backslash will quote any other character in the macro text, including " and '. For example, the following binding will make C-x \ insert a single \ into the line:
"\C-x\\": "\\"