| <html lang="en"> |
| <head> |
| <title>Readline Init File Syntax - Debugging with GDB</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="Debugging with GDB"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Readline-Init-File.html#Readline-Init-File" title="Readline Init File"> |
| <link rel="next" href="Conditional-Init-Constructs.html#Conditional-Init-Constructs" title="Conditional Init Constructs"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| Copyright (C) 1988-2019 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being ``Free Software'' and ``Free Software Needs |
| Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,'' |
| and with the Back-Cover Texts as in (a) below. |
| |
| (a) The FSF's Back-Cover Text is: ``You are free to copy and modify |
| this GNU Manual. Buying copies from GNU Press supports the FSF in |
| developing GNU and promoting software freedom.'' |
| --> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="Readline-Init-File-Syntax"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="Conditional-Init-Constructs.html#Conditional-Init-Constructs">Conditional Init Constructs</a>, |
| Up: <a rel="up" accesskey="u" href="Readline-Init-File.html#Readline-Init-File">Readline Init File</a> |
| <hr> |
| </div> |
| |
| <h4 class="subsection">32.3.1 Readline Init File Syntax</h4> |
| |
| <p>There are only a few basic constructs allowed in the |
| Readline init file. Blank lines are ignored. |
| Lines beginning with a ‘<samp><span class="samp">#</span></samp>’ are comments. |
| Lines beginning with a ‘<samp><span class="samp">$</span></samp>’ indicate conditional |
| constructs (see <a href="Conditional-Init-Constructs.html#Conditional-Init-Constructs">Conditional Init Constructs</a>). Other lines |
| denote variable settings and key bindings. |
| |
| <dl> |
| <dt>Variable Settings<dd>You can modify the run-time behavior of Readline by |
| altering the values of variables in Readline |
| using the <code>set</code> command within the init file. |
| The syntax is simple: |
| |
| <pre class="example"> set <var>variable</var> <var>value</var> |
| </pre> |
| <p class="noindent">Here, for example, is how to |
| change from the default Emacs-like key binding to use |
| <code>vi</code> line editing commands: |
| |
| <pre class="example"> set editing-mode vi |
| </pre> |
| <p>Variable names and values, where appropriate, are recognized without regard |
| to case. Unrecognized variable names are ignored. |
| |
| <p>Boolean variables (those that can be set to on or off) are set to on if |
| the value is null or empty, <var>on</var> (case-insensitive), or 1. Any other |
| value results in the variable being set to off. |
| |
| <p>A great deal of run-time behavior is changeable with the following |
| variables. |
| |
| <p><a name="index-variables_002c-readline-3188"></a> |
| <dl> |
| <dt><code>bell-style</code><dd><a name="index-bell_002dstyle-3189"></a>Controls what happens when Readline wants to ring the terminal bell. |
| If set to ‘<samp><span class="samp">none</span></samp>’, Readline never rings the bell. If set to |
| ‘<samp><span class="samp">visible</span></samp>’, Readline uses a visible bell if one is available. |
| If set to ‘<samp><span class="samp">audible</span></samp>’ (the default), Readline attempts to ring |
| the terminal's bell. |
| |
| <br><dt><code>bind-tty-special-chars</code><dd><a name="index-bind_002dtty_002dspecial_002dchars-3190"></a>If set to ‘<samp><span class="samp">on</span></samp>’, Readline attempts to bind the control characters |
| treated specially by the kernel's terminal driver to their Readline |
| equivalents. |
| |
| <br><dt><code>comment-begin</code><dd><a name="index-comment_002dbegin-3191"></a>The string to insert at the beginning of the line when the |
| <code>insert-comment</code> command is executed. The default value |
| is <code>"#"</code>. |
| |
| <br><dt><code>completion-display-width</code><dd><a name="index-completion_002ddisplay_002dwidth-3192"></a>The number of screen columns used to display possible matches |
| when performing completion. |
| The value is ignored if it is less than 0 or greater than the terminal |
| screen width. |
| A value of 0 will cause matches to be displayed one per line. |
| The default value is -1. |
| |
| <br><dt><code>completion-ignore-case</code><dd><a name="index-completion_002dignore_002dcase-3193"></a>If set to ‘<samp><span class="samp">on</span></samp>’, Readline performs filename matching and completion |
| in a case-insensitive fashion. |
| The default value is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>completion-map-case</code><dd><a name="index-completion_002dmap_002dcase-3194"></a>If set to ‘<samp><span class="samp">on</span></samp>’, and <var>completion-ignore-case</var> is enabled, Readline |
| treats hyphens (‘<samp><span class="samp">-</span></samp>’) and underscores (‘<samp><span class="samp">_</span></samp>’) as equivalent when |
| performing case-insensitive filename matching and completion. |
| |
| <br><dt><code>completion-prefix-display-length</code><dd><a name="index-completion_002dprefix_002ddisplay_002dlength-3195"></a>The length in characters of the common prefix of a list of possible |
| completions that is displayed without modification. When set to a |
| value greater than zero, common prefixes longer than this value are |
| replaced with an ellipsis when displaying possible completions. |
| |
| <br><dt><code>completion-query-items</code><dd><a name="index-completion_002dquery_002ditems-3196"></a>The number of possible completions that determines when the user is |
| asked whether the list of possibilities should be displayed. |
| If the number of possible completions is greater than this value, |
| Readline will ask the user whether or not he wishes to view |
| them; otherwise, they are simply listed. |
| This variable must be set to an integer value greater than or equal to 0. |
| A negative value means Readline should never ask. |
| The default limit is <code>100</code>. |
| |
| <br><dt><code>convert-meta</code><dd><a name="index-convert_002dmeta-3197"></a>If set to ‘<samp><span class="samp">on</span></samp>’, Readline will convert characters with the |
| eighth bit set to an <span class="sc">ascii</span> key sequence by stripping the eighth |
| bit and prefixing an <ESC> character, converting them to a |
| meta-prefixed key sequence. The default value is ‘<samp><span class="samp">on</span></samp>’. |
| |
| <br><dt><code>disable-completion</code><dd><a name="index-disable_002dcompletion-3198"></a>If set to ‘<samp><span class="samp">On</span></samp>’, Readline will inhibit word completion. |
| Completion characters will be inserted into the line as if they had |
| been mapped to <code>self-insert</code>. The default is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>editing-mode</code><dd><a name="index-editing_002dmode-3199"></a>The <code>editing-mode</code> 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 ‘<samp><span class="samp">emacs</span></samp>’ or ‘<samp><span class="samp">vi</span></samp>’. |
| |
| <br><dt><code>echo-control-characters</code><dd>When set to ‘<samp><span class="samp">on</span></samp>’, on operating systems that indicate they support it, |
| readline echoes a character corresponding to a signal generated from the |
| keyboard. The default is ‘<samp><span class="samp">on</span></samp>’. |
| |
| <br><dt><code>enable-keypad</code><dd><a name="index-enable_002dkeypad-3200"></a>When set to ‘<samp><span class="samp">on</span></samp>’, Readline will try to enable the application |
| keypad when it is called. Some systems need this to enable the |
| arrow keys. The default is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>enable-meta-key</code><dd>When set to ‘<samp><span class="samp">on</span></samp>’, Readline will try to enable any meta modifier |
| key the terminal claims to support when it is called. On many terminals, |
| the meta key is used to send eight-bit characters. |
| The default is ‘<samp><span class="samp">on</span></samp>’. |
| |
| <br><dt><code>expand-tilde</code><dd><a name="index-expand_002dtilde-3201"></a>If set to ‘<samp><span class="samp">on</span></samp>’, tilde expansion is performed when Readline |
| attempts word completion. The default is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>history-preserve-point</code><dd><a name="index-history_002dpreserve_002dpoint-3202"></a>If set to ‘<samp><span class="samp">on</span></samp>’, the history code attempts to place the point (the |
| current cursor position) at the |
| same location on each history line retrieved with <code>previous-history</code> |
| or <code>next-history</code>. The default is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>history-size</code><dd><a name="index-history_002dsize-3203"></a>Set the maximum number of history entries saved in the history list. If |
| set to zero, the number of entries in the history list is not limited. |
| |
| <br><dt><code>horizontal-scroll-mode</code><dd><a name="index-horizontal_002dscroll_002dmode-3204"></a>This variable can be set to either ‘<samp><span class="samp">on</span></samp>’ or ‘<samp><span class="samp">off</span></samp>’. Setting it |
| to ‘<samp><span class="samp">on</span></samp>’ means that the text of the lines being edited will scroll |
| horizontally on a single screen line when they are longer than the width |
| of the screen, instead of wrapping onto a new screen line. By default, |
| this variable is set to ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>input-meta</code><dd><a name="index-input_002dmeta-3205"></a><a name="index-meta_002dflag-3206"></a>If set to ‘<samp><span class="samp">on</span></samp>’, Readline will enable eight-bit input (it |
| will not clear the eighth bit in the characters it reads), |
| regardless of what the terminal claims it can support. The |
| default value is ‘<samp><span class="samp">off</span></samp>’. The name <code>meta-flag</code> is a |
| synonym for this variable. |
| |
| <br><dt><code>isearch-terminators</code><dd><a name="index-isearch_002dterminators-3207"></a>The string of characters that should terminate an incremental search without |
| subsequently executing the character as a command (see <a href="Searching.html#Searching">Searching</a>). |
| If this variable has not been given a value, the characters <ESC> and |
| <kbd>C-J</kbd> will terminate an incremental search. |
| |
| <br><dt><code>keymap</code><dd><a name="index-keymap-3208"></a>Sets Readline's idea of the current keymap for key binding commands. |
| Acceptable <code>keymap</code> names are |
| <code>emacs</code>, |
| <code>emacs-standard</code>, |
| <code>emacs-meta</code>, |
| <code>emacs-ctlx</code>, |
| <code>vi</code>, |
| <code>vi-move</code>, |
| <code>vi-command</code>, and |
| <code>vi-insert</code>. |
| <code>vi</code> is equivalent to <code>vi-command</code>; <code>emacs</code> is |
| equivalent to <code>emacs-standard</code>. The default value is <code>emacs</code>. |
| The value of the <code>editing-mode</code> variable also affects the |
| default keymap. |
| |
| <br><dt><code>mark-directories</code><dd>If set to ‘<samp><span class="samp">on</span></samp>’, completed directory names have a slash |
| appended. The default is ‘<samp><span class="samp">on</span></samp>’. |
| |
| <br><dt><code>mark-modified-lines</code><dd><a name="index-mark_002dmodified_002dlines-3209"></a>This variable, when set to ‘<samp><span class="samp">on</span></samp>’, causes Readline to display an |
| asterisk (‘<samp><span class="samp">*</span></samp>’) at the start of history lines which have been modified. |
| This variable is ‘<samp><span class="samp">off</span></samp>’ by default. |
| |
| <br><dt><code>mark-symlinked-directories</code><dd><a name="index-mark_002dsymlinked_002ddirectories-3210"></a>If set to ‘<samp><span class="samp">on</span></samp>’, completed names which are symbolic links |
| to directories have a slash appended (subject to the value of |
| <code>mark-directories</code>). |
| The default is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>match-hidden-files</code><dd><a name="index-match_002dhidden_002dfiles-3211"></a>This variable, when set to ‘<samp><span class="samp">on</span></samp>’, causes Readline to match files whose |
| names begin with a ‘<samp><span class="samp">.</span></samp>’ (hidden files) when performing filename |
| completion. |
| If set to ‘<samp><span class="samp">off</span></samp>’, the leading ‘<samp><span class="samp">.</span></samp>’ must be |
| supplied by the user in the filename to be completed. |
| This variable is ‘<samp><span class="samp">on</span></samp>’ by default. |
| |
| <br><dt><code>menu-complete-display-prefix</code><dd><a name="index-menu_002dcomplete_002ddisplay_002dprefix-3212"></a>If set to ‘<samp><span class="samp">on</span></samp>’, menu completion displays the common prefix of the |
| list of possible completions (which may be empty) before cycling through |
| the list. The default is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>output-meta</code><dd><a name="index-output_002dmeta-3213"></a>If set to ‘<samp><span class="samp">on</span></samp>’, Readline will display characters with the |
| eighth bit set directly rather than as a meta-prefixed escape |
| sequence. The default is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>page-completions</code><dd><a name="index-page_002dcompletions-3214"></a>If set to ‘<samp><span class="samp">on</span></samp>’, Readline uses an internal <code>more</code>-like pager |
| to display a screenful of possible completions at a time. |
| This variable is ‘<samp><span class="samp">on</span></samp>’ by default. |
| |
| <br><dt><code>print-completions-horizontally</code><dd>If set to ‘<samp><span class="samp">on</span></samp>’, Readline will display completions with matches |
| sorted horizontally in alphabetical order, rather than down the screen. |
| The default is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>revert-all-at-newline</code><dd><a name="index-revert_002dall_002dat_002dnewline-3215"></a>If set to ‘<samp><span class="samp">on</span></samp>’, Readline will undo all changes to history lines |
| before returning when <code>accept-line</code> is executed. By default, |
| history lines may be modified and retain individual undo lists across |
| calls to <code>readline</code>. The default is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>show-all-if-ambiguous</code><dd><a name="index-show_002dall_002dif_002dambiguous-3216"></a>This alters the default behavior of the completion functions. If |
| set to ‘<samp><span class="samp">on</span></samp>’, |
| words which have more than one possible completion cause the |
| matches to be listed immediately instead of ringing the bell. |
| The default value is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>show-all-if-unmodified</code><dd><a name="index-show_002dall_002dif_002dunmodified-3217"></a>This alters the default behavior of the completion functions in |
| a fashion similar to <var>show-all-if-ambiguous</var>. |
| If set to ‘<samp><span class="samp">on</span></samp>’, |
| words which have more than one possible completion without any |
| possible partial completion (the possible completions don't share |
| a common prefix) cause the matches to be listed immediately instead |
| of ringing the bell. |
| The default value is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>skip-completed-text</code><dd><a name="index-skip_002dcompleted_002dtext-3218"></a>If set to ‘<samp><span class="samp">on</span></samp>’, this alters the default completion behavior when |
| inserting a single match into the line. It's only active when |
| performing completion in the middle of a word. If enabled, readline |
| does not insert characters from the completion that match characters |
| after point in the word being completed, so portions of the word |
| following the cursor are not duplicated. |
| For instance, if this is enabled, attempting completion when the cursor |
| is after the ‘<samp><span class="samp">e</span></samp>’ in ‘<samp><span class="samp">Makefile</span></samp>’ will result in ‘<samp><span class="samp">Makefile</span></samp>’ |
| rather than ‘<samp><span class="samp">Makefilefile</span></samp>’, assuming there is a single possible |
| completion. |
| The default value is ‘<samp><span class="samp">off</span></samp>’. |
| |
| <br><dt><code>visible-stats</code><dd><a name="index-visible_002dstats-3219"></a>If set to ‘<samp><span class="samp">on</span></samp>’, a character denoting a file's type |
| is appended to the filename when listing possible |
| completions. The default is ‘<samp><span class="samp">off</span></samp>’. |
| |
| </dl> |
| |
| <br><dt>Key Bindings<dd>The syntax for controlling key bindings in the init file is |
| simple. First you need to find the name of the command that you |
| want to change. The following sections contain tables of the command |
| name, the default keybinding, if any, and a short description of what |
| the command does. |
| |
| <p>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. |
| |
| <p>In addition to command names, readline allows keys to be bound |
| to a string that is inserted when the key is pressed (a <var>macro</var>). |
| |
| <dl> |
| <dt><var>keyname</var>: <var>function-name</var> or <var>macro</var><!-- /@w --><dd><var>keyname</var> is the name of a key spelled out in English. For example: |
| <pre class="example"> Control-u: universal-argument |
| Meta-Rubout: backward-kill-word |
| Control-o: "> output" |
| </pre> |
| <p>In the above example, <kbd>C-u</kbd> is bound to the function |
| <code>universal-argument</code>, |
| <kbd>M-DEL</kbd> is bound to the function <code>backward-kill-word</code>, and |
| <kbd>C-o</kbd> is bound to run the macro |
| expressed on the right hand side (that is, to insert the text |
| ‘<samp><span class="samp">> output</span></samp>’ into the line). |
| |
| <p>A number of symbolic character names are recognized while |
| processing this key binding syntax: |
| <var>DEL</var>, |
| <var>ESC</var>, |
| <var>ESCAPE</var>, |
| <var>LFD</var>, |
| <var>NEWLINE</var>, |
| <var>RET</var>, |
| <var>RETURN</var>, |
| <var>RUBOUT</var>, |
| <var>SPACE</var>, |
| <var>SPC</var>, |
| and |
| <var>TAB</var>. |
| |
| <br><dt>"<var>keyseq</var>": <var>function-name</var> or <var>macro</var><!-- /@w --><dd><var>keyseq</var> differs from <var>keyname</var> above in that strings |
| denoting an entire key sequence can be specified, by placing |
| the key sequence in double quotes. Some <span class="sc">gnu</span> Emacs style key |
| escapes can be used, as in the following example, but the |
| special character names are not recognized. |
| |
| <pre class="example"> "\C-u": universal-argument |
| "\C-x\C-r": re-read-init-file |
| "\e[11~": "Function Key 1" |
| </pre> |
| <p>In the above example, <kbd>C-u</kbd> is again bound to the function |
| <code>universal-argument</code> (just as it was in the first example), |
| ‘<samp><kbd>C-x</kbd> <kbd>C-r</kbd></samp>’ is bound to the function <code>re-read-init-file</code>, |
| and ‘<samp><span class="samp"><ESC> <[> <1> <1> <~></span></samp>’ is bound to insert |
| the text ‘<samp><span class="samp">Function Key 1</span></samp>’. |
| |
| </dl> |
| |
| <p>The following <span class="sc">gnu</span> Emacs style escape sequences are available when |
| specifying key sequences: |
| |
| <dl> |
| <dt><kbd>\C-</kbd><dd>control prefix |
| <br><dt><kbd>\M-</kbd><dd>meta prefix |
| <br><dt><kbd>\e</kbd><dd>an escape character |
| <br><dt><kbd>\\</kbd><dd>backslash |
| <br><dt><kbd>\"</kbd><dd><">, a double quotation mark |
| <br><dt><kbd>\'</kbd><dd><'>, a single quote or apostrophe |
| </dl> |
| |
| <p>In addition to the <span class="sc">gnu</span> Emacs style escape sequences, a second |
| set of backslash escapes is available: |
| |
| <dl> |
| <dt><code>\a</code><dd>alert (bell) |
| <br><dt><code>\b</code><dd>backspace |
| <br><dt><code>\d</code><dd>delete |
| <br><dt><code>\f</code><dd>form feed |
| <br><dt><code>\n</code><dd>newline |
| <br><dt><code>\r</code><dd>carriage return |
| <br><dt><code>\t</code><dd>horizontal tab |
| <br><dt><code>\v</code><dd>vertical tab |
| <br><dt><code>\</code><var>nnn</var><dd>the eight-bit character whose value is the octal value <var>nnn</var> |
| (one to three digits) |
| <br><dt><code>\x</code><var>HH</var><dd>the eight-bit character whose value is the hexadecimal value <var>HH</var> |
| (one or two hex digits) |
| </dl> |
| |
| <p>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 ‘<samp><span class="samp">"</span></samp>’ and ‘<samp><span class="samp">'</span></samp>’. |
| For example, the following binding will make ‘<samp><kbd>C-x</kbd><span class="samp"> \</span></samp>’ |
| insert a single ‘<samp><span class="samp">\</span></samp>’ into the line: |
| <pre class="example"> "\C-x\\": "\\" |
| </pre> |
| </dl> |
| |
| </body></html> |
| |