Readline implements a facility similar in spirit to the conditional compilation features of the C preprocessor which allows key bindings and variable settings to be performed as the result of tests. There are four parser directives used.
$ifconstruct allows bindings to be made based on the editing mode, the terminal being used, or the application using Readline. The text of the test extends to the end of the line; no characters are required to isolate it.
mode=form of the
$ifdirective is used to test whether Readline is in
vimode. This may be used in conjunction with the ‘set keymap’ command, for instance, to set bindings in the
emacs-ctlxkeymaps only if Readline is starting out in
term=form may be used to include terminal-specific key bindings, perhaps to bind the key sequences output by the terminal's function keys. The word on the right side of the ‘=’ is tested against both the full name of the terminal and the portion of the terminal name before the first ‘-’. This allows
sunto match both
sun-cmd, for instance.
$if Bash # Quote the current or previous word "\C-xq": "\eb\"\ef\"" $endif
$ifdirective are executed if the test fails.