Chapter 29. Command Line Editing
299
29.3.2. Conditional Init Constructs
Readline implements a facility similar in spirit to the conditional compilation features of the C pre-
processor which allows key bindings and variable settings to be performed as the result of tests. There
are four parser directives used.
$if
The
$if
construct 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
The
mode=
form of the
$if
directive is used to test whether Readline is in
emacs
or
vi
mode. This may be used in conjunction with the
set keymap
command, for instance, to
set bindings in the
emacs-standard
and
emacs-ctlx
keymaps only if Readline is starting
out in
emacs
mode.
term
The
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
sun
to match both
sun
and
sun-cmd
, for instance.
application
The
application
construct is used to include application-specific settings. Each program
using the Readline library sets the
application name
, and you can test for a particular
value. This could be used to bind key sequences to functions useful for a specific program.
For instance, the following command adds a key sequence that quotes the current or previous
word in Bash:
$if Bash
# Quote the current or previous word
"\C-xq": "\eb\"\ef\""
$endif
$endif
This command, as seen in the previous example, terminates an
$if
command.
$else
Commands in this branch of the
$if
directive are executed if the test fails.
$include
This directive takes a single filename as an argument and reads commands and bindings from
that file. For example, the following directive reads from
/etc/inputrc
:
$include /etc/inputrc
29.3.3. Sample Init File
Here is an example of an
inputrc
file. This illustrates key binding, variable assignment, and condi-
tional syntax.
# This file controls the behaviour of line input editing for
Summary of Contents for ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Page 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......