|Debugging with GDB|
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.
setcommand within the init file. The syntax is simple:
set variable value
Here, for example, is how to
change from the default Emacs-like key binding to use
vi line editing commands:
set editing-mode vi
Variable names and values, where appropriate, are recognized without regard to case. Unrecognized variable names are ignored.
Boolean variables (those that can be set to on or off) are set to on if the value is null or empty, on (case-insensitive), or 1. Any other value results in the variable being set to off.
A great deal of run-time behavior is changeable with the following variables.
insert-commentcommand is executed. The default value is
self-insert. The default is ‘off’.
editing-modevariable 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’.
next-history. The default is ‘off’.
meta-flagis a synonym for this variable.
viis equivalent to
emacsis equivalent to
emacs-standard. The default value is
emacs. The value of the
editing-modevariable also affects the default keymap.
mark-directories). The default is ‘off’.
more-like pager to display a screenful of possible completions at a time. This variable is ‘on’ by default.
accept-lineis executed. By default, history lines may be modified and retain individual undo lists across calls to
readline. The default is ‘off’.
Once you know the name of the command, simply place on a line in the init file the name of the key you wish to bind the command to, a colon, and then the name of the command. There can be no space between the key name and the colon – that will be interpreted as part of the key name. The name of the key can be expressed in different ways, depending on what you find most comfortable.
In addition to command names, readline allows keys to be bound to a string that is inserted when the key is pressed (a macro).
Control-u: universal-argument Meta-Rubout: backward-kill-word Control-o: "> output"
In the above example, C-u is bound to the function
M-DEL is bound to the function
C-o is bound to run the macro
expressed on the right hand side (that is, to insert the text
‘> output’ into the line).
A number of symbolic character names are recognized while
processing this key binding syntax:
"\C-u": universal-argument "\C-x\C-r": re-read-init-file "\e[11~": "Function Key 1"
In the above example, C-u is again bound to the function
universal-argument (just as it was in the first example),
‘C-x C-r’ is bound to the function
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:
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: