-->

Previous | Table of Contents | Next

Page 28

When entering the text of a macro, single or double quotes should be used to indicate a macro definition. Unquoted text is assumed to be a function name. Backslash will quote any character in the macro text, including " and `.

bash allows the current readline key bindings to be displayed or modified with the bind built-in command. The editing mode may be switched during interactive use by using the _o option to the set built-in command. (See "Shell Built-in Commands.")

Readline has variables that can be used to further customize its behavior. A variable may be set in the inputrc file with a statement of the form:


set variable_name value

Except where noted, readline variables can take the values On or Off. The variables and their default values are as follows:

horizontal_scroll_mode (Off) When set to On, makes readline use a single line for display, scrolling the input horizontally on a single screen line when it becomes longer than the screen width rather than wrapping to a new line.

editing_mode (emacs) Controls whether readline begins with a set of key bindings similar to emacs or vi. editing_mode can be set to either emacs or vi.
mark_modified_lines (Off) If set to On, history lines that have been modified are displayed with a preceding asterisk (*).
bell_style (audible) Controls what happens when readline wants to ring the terminal bell. If set to none, readline never rings the bell. If set to visible, readline uses a visible bell if one is available. If set to audible, readline attempts to ring the terminal's bell.
comment_begin ("#") The string that is inserted in vi mode when the vi_comment command is executed.
meta_flag (Off) If set to On, readline will enable eight-bit input (that is, it will not strip the high bit from the characters it reads), regardless of what the terminal claims it can support.
convert_meta (On) If set to On, readline will convert characters with the eighth bit set to an ASCII key sequence by stripping the eighth bit and prepending an escape character (in effect, using escape as the meta prefix).
output_meta (Off) If set to On, readline will display characters with the eighth bit set directly rather than as a meta-prefixed escape sequence.
completion_query_items (100) This determines when the user is queried about viewing the number of possible completions generated by the possible_completions command. It may be set to any integer value greater than or equal to zero. If the number of possible completions is greater than or equal to the value of this variable, the user is asked whether or not he wishes to view them; otherwise, they are simply listed on the terminal.
keymap (emacs) Set the current readline keymap. The set of legal keymap names is emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move, 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 editing_mode also affects the default keymap.
show_all_if_ambiguous (Off) This alters the default behavior of the completion functions. If set to On, words which have more than one possible completion cause the matches to be listed immediately instead of ringing the bell.
expand_tilde (Off) If set to On, tilde expansion is performed when readline attempts word completion.

Readline implements a facility similar in spirit to the conditional compilation features of the C preprocessor that allows key bindings and variable settings to be performed as the result of tests. There are three 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.

Page 29

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 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 an initialization file 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 shown in the preceding example, terminates an $if command.
$else Commands in this branch of the $if directive are executed if the test fails.

readline commands may be given numeric arguments, which normally act as a repeat count. Sometimes, however, it is the sign of the argument that is significant. Passing a negative argument to a command that acts in the forward direction (such as kill_line) causes that command to act in a backward direction. Commands whose behavior with arguments deviates from this are noted.

When a command is described as killing text, the text deleted is saved for possible future retrieval (yanking). The killed text is saved in a kill_ring. Consecutive kills cause the text to be accumulated into one unit, which can be yanked all at once. Commands that do not kill text separate the chunks of text on the kill_ring.

The following is a list of the names of the commands and the default key sequences to which they are bound.

Commands for Moving

beginning_of_line (C_a) Move to the start of the current line.
end_of_line (C_e) Move to the end of the line.
forward_char (C_f) Move forward a character.
backward_char (C_b) Move back a character.
forward_word (M_f) Move forward to the end of the next word. Words are composed of alphanumeric characters (letters and digits).
backward_word (M_b) Move back to the start of this, or the previous, word. Words are composed of alphanumeric characters (letters and digits).
clear_screen (C_l) Clear the screen leaving the current line at the top of the screen. With an argument, refresh the current line without clearing the screen.
redraw_current_line Refresh the current line. By default, this is unbound.

Previous | Table of Contents | Next