1READLINE(3)                Library Functions Manual                READLINE(3)
2
3
4

NAME

6       readline - get a line from a user with editing
7

SYNOPSIS

9       #include <stdio.h>
10       #include <readline/readline.h>
11       #include <readline/history.h>
12
13       char *
14       readline (const char *prompt);
15
17       Readline is Copyright (C) 1989-2020 Free Software Foundation,  Inc.
18

DESCRIPTION

20       readline will read a line from the terminal and return it, using prompt
21       as a prompt.  If prompt is NULL or the empty string, no prompt  is  is‐
22       sued.   The  line returned is allocated with malloc(3); the caller must
23       free it when finished.  The line returned has  the  final  newline  re‐
24       moved, so only the text of the line remains.
25
26       readline  offers  editing  capabilities  while the user is entering the
27       line.  By default, the line editing commands are similar  to  those  of
28       emacs.  A vi-style line editing interface is also available.
29
30       This  manual  page describes only the most basic use of readline.  Much
31       more functionality is available; see The GNU Readline Library  and  The
32       GNU History Library for additional information.
33

RETURN VALUE

35       readline  returns  the text of the line read.  A blank line returns the
36       empty string.  If EOF is encountered while reading a line, and the line
37       is  empty,  NULL is returned.  If an EOF is read with a non-empty line,
38       it is treated as a newline.
39

NOTATION

41       An Emacs-style notation is used to denote keystrokes.  Control keys are
42       denoted  by C-key, e.g., C-n means Control-N.  Similarly, meta keys are
43       denoted by M-key, so M-x means Meta-X.  (On keyboards  without  a  meta
44       key,  M-x means ESC x, i.e., press the Escape key then the x key.  This
45       makes ESC the meta prefix.  The combination M-C-x means  ESC-Control-x,
46       or  press the Escape key then hold the Control key while pressing the x
47       key.)
48
49       Readline commands may be given numeric arguments, which normally act as
50       a  repeat  count.   Sometimes,  however, it is the sign of the argument
51       that is significant.  Passing a negative argument  to  a  command  that
52       acts  in the forward direction (e.g., kill-line) causes that command to
53       act in a backward direction.  Commands whose  behavior  with  arguments
54       deviates from this are noted below.
55
56       When  a command is described as killing text, the text deleted is saved
57       for possible future retrieval (yanking).  The killed text is saved in a
58       kill ring.  Consecutive kills cause the text to be accumulated into one
59       unit, which can be yanked all at once.  Commands which do not kill text
60       separate the chunks of text on the kill ring.
61

INITIALIZATION FILE

63       Readline  is  customized  by putting commands in an initialization file
64       (the inputrc file).  The name of this file is taken from the  value  of
65       the  INPUTRC  environment variable.  If that variable is unset, the de‐
66       fault is ~/.inputrc.  If that file  does not exist or cannot  be  read,
67       the  ultimate  default  is /etc/inputrc.  When a program which uses the
68       readline library starts up, the init file is read, and the key bindings
69       and  variables  are set.  There are only a few basic constructs allowed
70       in the readline init file.  Blank lines are ignored.   Lines  beginning
71       with  a  # are comments.  Lines beginning with a $ indicate conditional
72       constructs.  Other lines denote key  bindings  and  variable  settings.
73       Each program using this library may add its own commands and bindings.
74
75       For example, placing
76
77              M-Control-u: universal-argument
78       or
79              C-Meta-u: universal-argument
80
81       into  the inputrc would make M-C-u execute the readline command univer‐
82       sal-argument.
83
84       The following symbolic character names are recognized while  processing
85       key  bindings:  DEL,  ESC,  ESCAPE,  LFD, NEWLINE, RET, RETURN, RUBOUT,
86       SPACE, SPC, and TAB.
87
88       In addition to command names, readline allows keys to  be  bound  to  a
89       string that is inserted when the key is pressed (a macro).
90
91   Key Bindings
92       The  syntax for controlling key bindings in the inputrc file is simple.
93       All that is required is the name of the command or the text of a  macro
94       and a key sequence to which it should be bound.  The name may be speci‐
95       fied in one of two ways: as a symbolic key name, possibly with Meta- or
96       Control- prefixes, or as a key sequence.  The name and key sequence are
97       separated by a colon.  There can be no whitespace between the name  and
98       the colon.
99
100       When using the form keyname:function-name or macro, keyname is the name
101       of a key spelled out in English.  For example:
102
103              Control-u: universal-argument
104              Meta-Rubout: backward-kill-word
105              Control-o: "> output"
106
107       In the above example, C-u is bound to the function  universal-argument,
108       M-DEL  is bound to the function backward-kill-word, and C-o is bound to
109       run the macro expressed on the right hand side (that is, to insert  the
110       text ``> output'' into the line).
111
112       In  the  second  form,  "keyseq":function-name or macro, keyseq differs
113       from keyname above in that strings denoting an entire key sequence  may
114       be  specified  by  placing the sequence within double quotes.  Some GNU
115       Emacs style key escapes can be used, as in the following  example,  but
116       the symbolic character names are not recognized.
117
118              "\C-u": universal-argument
119              "\C-x\C-r": re-read-init-file
120              "\e[11~": "Function Key 1"
121
122       In this example, C-u is again bound to the function universal-argument.
123       C-x C-r is bound to the function re-read-init-file, and ESC [ 1 1 ~  is
124       bound to insert the text ``Function Key 1''.
125
126       The  full set of GNU Emacs style escape sequences available when speci‐
127       fying key sequences is
128              \C-    control prefix
129              \M-    meta prefix
130              \e     an escape character
131              \\     backslash
132              \"     literal ", a double quote
133              \'     literal ', a single quote
134
135       In addition to the GNU Emacs style escape sequences, a  second  set  of
136       backslash escapes is available:
137              \a     alert (bell)
138              \b     backspace
139              \d     delete
140              \f     form feed
141              \n     newline
142              \r     carriage return
143              \t     horizontal tab
144              \v     vertical tab
145              \nnn   the  eight-bit  character  whose value is the octal value
146                     nnn (one to three digits)
147              \xHH   the eight-bit character whose value  is  the  hexadecimal
148                     value HH (one or two hex digits)
149
150       When  entering  the  text of a macro, single or double quotes should be
151       used to indicate a macro definition.  Unquoted text is assumed to be  a
152       function  name.   In  the  macro  body, the backslash escapes described
153       above are expanded.  Backslash will quote any other  character  in  the
154       macro text, including " and '.
155
156       Bash  allows the current readline key bindings to be displayed or modi‐
157       fied with the bind builtin command.  The editing mode may  be  switched
158       during  interactive  use by using the -o option to the set builtin com‐
159       mand.  Other programs using this library  provide  similar  mechanisms.
160       The  inputrc  file may be edited and re-read if a program does not pro‐
161       vide any other means to incorporate new bindings.
162
163   Variables
164       Readline has variables that can be used to further customize its behav‐
165       ior.  A variable may be set in the inputrc file with a statement of the
166       form
167
168              set variable-name value
169
170       Except where noted, readline variables can take the values  On  or  Off
171       (without  regard  to  case).   Unrecognized variable names are ignored.
172       When a variable value is read, empty or null values, "on"  (case-insen‐
173       sitive), and "1" are equivalent to On.  All other values are equivalent
174       to Off.  The variables and their default values are:
175
176       bell-style (audible)
177              Controls what happens when readline wants to ring  the  terminal
178              bell.  If set to none, readline never rings the bell.  If set to
179              visible, readline uses a visible bell if one is  available.   If
180              set to audible, readline attempts to ring the terminal's bell.
181       bind-tty-special-chars (On)
182              If  set  to On (the default), readline attempts to bind the con‐
183              trol characters   treated specially  by  the  kernel's  terminal
184              driver to their readline equivalents.
185       blink-matching-paren (Off)
186              If set to On, readline attempts to briefly move the cursor to an
187              opening parenthesis when a closing parenthesis is inserted.
188       colored-completion-prefix (Off)
189              If set to On, when listing completions,  readline  displays  the
190              common prefix of the set of possible completions using a differ‐
191              ent color.  The color definitions are taken from  the  value  of
192              the LS_COLORS environment variable.
193       colored-stats (Off)
194              If  set to On, readline displays possible completions using dif‐
195              ferent colors to indicate their file type.   The  color  defini‐
196              tions  are  taken  from  the  value of the LS_COLORS environment
197              variable.
198       comment-begin (``#'')
199              The string that is inserted in vi mode when  the  insert-comment
200              command is executed.  This command is bound to M-# in emacs mode
201              and to # in vi command mode.
202       completion-display-width (-1)
203              The number of screen columns used to  display  possible  matches
204              when  performing completion.  The value is ignored if it is less
205              than 0 or greater than the terminal screen width.  A value of  0
206              will  cause  matches  to be displayed one per line.  The default
207              value is -1.
208       completion-ignore-case (Off)
209              If set to On, readline performs filename matching and completion
210              in a case-insensitive fashion.
211       completion-map-case (Off)
212              If  set  to  On, and completion-ignore-case is enabled, readline
213              treats hyphens (-) and underscores (_) as equivalent  when  per‐
214              forming case-insensitive filename matching and completion.
215       completion-prefix-display-length (0)
216              The  length in characters of the common prefix of a list of pos‐
217              sible completions that is displayed without modification.   When
218              set  to  a  value greater than zero, common prefixes longer than
219              this value are replaced with an ellipsis when displaying  possi‐
220              ble completions.
221       completion-query-items (100)
222              This  determines when the user is queried about viewing the num‐
223              ber of possible completions generated  by  the  possible-comple‐
224              tions  command.  It may be set to any integer value greater than
225              or equal to zero.  If the  number  of  possible  completions  is
226              greater  than  or  equal to the value of this variable, readline
227              will ask whether or not the user wishes to view them;  otherwise
228              they are simply listed on the terminal.  A negative value causes
229              readline to never ask.
230       convert-meta (On)
231              If set to On, readline will convert characters with  the  eighth
232              bit set to an ASCII key sequence by stripping the eighth bit and
233              prefixing it with an escape character (in effect,  using  escape
234              as  the  meta prefix).  The default is On, but readline will set
235              it to Off if the locale contains eight-bit characters.
236       disable-completion (Off)
237              If set to On, readline will inhibit word completion.  Completion
238              characters  will  be  inserted into the line as if they had been
239              mapped to self-insert.
240       echo-control-characters (On)
241              When set to On, on operating systems that indicate they  support
242              it, readline echoes a character corresponding to a signal gener‐
243              ated from the keyboard.
244       editing-mode (emacs)
245              Controls whether readline begins with a set of key bindings sim‐
246              ilar to Emacs or vi.  editing-mode can be set to either emacs or
247              vi.
248       emacs-mode-string (@)
249              If the show-mode-in-prompt variable is enabled, this  string  is
250              displayed immediately before the last line of the primary prompt
251              when emacs editing mode is active.  The value is expanded like a
252              key  binding,  so the standard set of meta- and control prefixes
253              and backslash escape sequences is available.  Use the \1 and  \2
254              escapes  to  begin and end sequences of non-printing characters,
255              which can be used to embed a terminal control sequence into  the
256              mode string.
257       enable-bracketed-paste (On)
258              When  set  to  On, readline will configure the terminal in a way
259              that will enable it to insert each paste into the editing buffer
260              as a single string of characters, instead of treating each char‐
261              acter as if it had been read from the keyboard.  This  can  pre‐
262              vent  pasted  characters  from being interpreted as editing com‐
263              mands.
264       enable-keypad (Off)
265              When set to On, readline will try to enable the application key‐
266              pad when it is called.  Some systems need this to enable the ar‐
267              row keys.
268       enable-meta-key (On)
269              When set to On, readline will try to enable  any  meta  modifier
270              key  the  terminal claims to support when it is called.  On many
271              terminals, the meta key is used to send eight-bit characters.
272       expand-tilde (Off)
273              If set to On, tilde expansion is  performed  when  readline  at‐
274              tempts word completion.
275       history-preserve-point (Off)
276              If  set  to  On, the history code attempts to place point at the
277              same location on each history line retrieved with  previous-his‐
278              tory or next-history.
279       history-size (unset)
280              Set  the  maximum number of history entries saved in the history
281              list.  If set to zero, any existing history entries are  deleted
282              and no new entries are saved.  If set to a value less than zero,
283              the number of history entries is not limited.  By  default,  the
284              number of history entries is not limited.  If an attempt is made
285              to set history-size to a non-numeric value, the  maximum  number
286              of history entries will be set to 500.
287       horizontal-scroll-mode (Off)
288              When  set  to  On, makes readline use a single line for display,
289              scrolling the input horizontally on a single screen line when it
290              becomes  longer  than the screen width rather than wrapping to a
291              new line.  This setting is automatically enabled  for  terminals
292              of height 1.
293       input-meta (Off)
294              If  set to On, readline will enable eight-bit input (that is, it
295              will not clear the eighth bit in the characters it  reads),  re‐
296              gardless  of  what the terminal claims it can support.  The name
297              meta-flag is a synonym for this variable.  The default  is  Off,
298              but  readline will set it to On if the locale contains eight-bit
299              characters.
300       isearch-terminators (``C-[ C-J'')
301              The string of characters that should  terminate  an  incremental
302              search  without  subsequently  executing the character as a com‐
303              mand.  If this variable has not been given a value, the  charac‐
304              ters ESC and C-J will terminate an incremental search.
305       keymap (emacs)
306              Set  the current readline keymap.  The set of legal keymap names
307              is emacs, emacs-standard, emacs-meta, emacs-ctlx,  vi,  vi-move,
308              vi-command,  and  vi-insert.   vi  is  equivalent to vi-command;
309              emacs is equivalent to emacs-standard.   The  default  value  is
310              emacs.   The  value  of  editing-mode  also  affects the default
311              keymap.
312       keyseq-timeout (500)
313              Specifies the duration readline will wait for a  character  when
314              reading  an ambiguous key sequence (one that can form a complete
315              key sequence using the input read so far, or can take additional
316              input  to  complete  a longer key sequence).  If no input is re‐
317              ceived within the timeout, readline will  use  the  shorter  but
318              complete  key sequence.  The value is specified in milliseconds,
319              so a value of 1000 means that readline will wait one second  for
320              additional  input.  If this variable is set to a value less than
321              or equal to zero, or to a non-numeric value, readline will  wait
322              until  another  key  is  pressed to decide which key sequence to
323              complete.
324       mark-directories (On)
325              If set to On, completed directory names have a slash appended.
326       mark-modified-lines (Off)
327              If set to On, history lines that have  been  modified  are  dis‐
328              played with a preceding asterisk (*).
329       mark-symlinked-directories (Off)
330              If set to On, completed names which are symbolic links to direc‐
331              tories have a slash appended (subject to the value  of  mark-di‐
332              rectories).
333       match-hidden-files (On)
334              This  variable,  when  set to On, causes readline to match files
335              whose names begin with a  `.'  (hidden  files)  when  performing
336              filename  completion.   If  set  to Off, the leading `.' must be
337              supplied by the user in the filename to be completed.
338       menu-complete-display-prefix (Off)
339              If set to On, menu completion displays the common prefix of  the
340              list of possible completions (which may be empty) before cycling
341              through the list.
342       output-meta (Off)
343              If set to On, readline will display characters with  the  eighth
344              bit set directly rather than as a meta-prefixed escape sequence.
345              The default is Off, but readline will set it to On if the locale
346              contains eight-bit characters.
347       page-completions (On)
348              If  set to On, readline uses an internal more-like pager to dis‐
349              play a screenful of possible completions at a time.
350       print-completions-horizontally (Off)
351              If set to On, readline will  display  completions  with  matches
352              sorted  horizontally in alphabetical order, rather than down the
353              screen.
354       revert-all-at-newline (Off)
355              If set to On, readline will undo all changes  to  history  lines
356              before returning when accept-line is executed.  By default, his‐
357              tory lines may be modified  and  retain  individual  undo  lists
358              across calls to readline.
359       show-all-if-ambiguous (Off)
360              This  alters  the  default behavior of the completion functions.
361              If set to On, words which have more than one possible completion
362              cause  the  matches  to be listed immediately instead of ringing
363              the bell.
364       show-all-if-unmodified (Off)
365              This alters the default behavior of the completion functions  in
366              a fashion similar to show-all-if-ambiguous.  If set to On, words
367              which have more than one possible completion without any  possi‐
368              ble  partial  completion (the possible completions don't share a
369              common prefix) cause the matches to be  listed  immediately  in‐
370              stead of ringing the bell.
371       show-mode-in-prompt (Off)
372              If  set to On, add a string to the beginning of the prompt indi‐
373              cating the editing mode: emacs, vi  command,  or  vi  insertion.
374              The mode strings are user-settable (e.g., emacs-mode-string).
375       skip-completed-text (Off)
376              If  set  to On, this alters the default completion behavior when
377              inserting a single match into the line.  It's only  active  when
378              performing  completion  in  the  middle  of a word.  If enabled,
379              readline does not insert characters  from  the  completion  that
380              match  characters  after  point  in the word being completed, so
381              portions of the word following the cursor are not duplicated.
382       vi-cmd-mode-string ((cmd))
383              If the show-mode-in-prompt variable is enabled, this  string  is
384              displayed immediately before the last line of the primary prompt
385              when vi editing mode is active and in command mode.   The  value
386              is expanded like a key binding, so the standard set of meta- and
387              control prefixes and backslash escape  sequences  is  available.
388              Use  the  \1  and  \2 escapes to begin and end sequences of non-
389              printing characters, which can be used to embed a terminal  con‐
390              trol sequence into the mode string.
391       vi-ins-mode-string ((ins))
392              If  the  show-mode-in-prompt variable is enabled, this string is
393              displayed immediately before the last line of the primary prompt
394              when vi editing mode is active and in insertion mode.  The value
395              is expanded like a key binding, so the standard set of meta- and
396              control  prefixes  and  backslash escape sequences is available.
397              Use the \1 and \2 escapes to begin and  end  sequences  of  non-
398              printing  characters, which can be used to embed a terminal con‐
399              trol sequence into the mode string.
400       visible-stats (Off)
401              If set to On, a character denoting a file's type as reported  by
402              stat(2)  is  appended to the filename when listing possible com‐
403              pletions.
404
405   Conditional Constructs
406       Readline implements a facility similar in  spirit  to  the  conditional
407       compilation  features  of  the C preprocessor which allows key bindings
408       and variable settings to be performed as the result  of  tests.   There
409       are four parser directives used.
410
411       $if    The  $if construct allows bindings to be made based on the edit‐
412              ing mode, the terminal being  used,  or  the  application  using
413              readline.   The text of the test, after any comparison operator,
414              extends to the end of the line; unless otherwise noted, no char‐
415              acters are required to isolate it.
416
417              mode   The  mode=  form  of  the  $if  directive is used to test
418                     whether readline is in emacs or vi  mode.   This  may  be
419                     used  in conjunction with the set keymap command, for in‐
420                     stance, to set bindings in the emacs-standard and  emacs-
421                     ctlx  keymaps  only  if readline is starting out in emacs
422                     mode.
423
424              term   The term= form may be used to  include  terminal-specific
425                     key bindings, perhaps to bind the key sequences output by
426                     the terminal's function keys.  The word on the right side
427                     of  the = is tested against the full name of the terminal
428                     and the portion of the terminal name before the first  -.
429                     This  allows  sun  to match both sun and sun-cmd, for in‐
430                     stance.
431
432              version
433                     The version test  may  be  used  to  perform  comparisons
434                     against  specific readline versions.  The version expands
435                     to the current readline version.  The set  of  comparison
436                     operators  includes  =,  (and  ==), !=, <=, >=, <, and >.
437                     The version number supplied on the right side of the  op‐
438                     erator  consists  of  a major version number, an optional
439                     decimal point, and an optional minor version (e.g., 7.1).
440                     If  the  minor version is omitted, it is assumed to be 0.
441                     The operator may be separated from the string version and
442                     from the version number argument by whitespace.
443
444              application
445                     The application construct is used to include application-
446                     specific settings.  Each program using the  readline  li‐
447                     brary  sets  the  application name, and an initialization
448                     file can test for a particular value.  This could be used
449                     to  bind key sequences to functions useful for a specific
450                     program.  For instance, the following command adds a  key
451                     sequence  that  quotes  the  current  or previous word in
452                     bash:
453
454                     $if Bash
455                     # Quote the current or previous word
456                     "\C-xq": "\eb\"\ef\""
457                     $endif
458
459              variable
460                     The variable construct provides simple equality tests for
461                     readline  variables and values.  The permitted comparison
462                     operators are =, ==, and !=.  The variable name  must  be
463                     separated from the comparison operator by whitespace; the
464                     operator may be separated from the  value  on  the  right
465                     hand  side  by whitespace.  Both string and boolean vari‐
466                     ables may be tested. Boolean  variables  must  be  tested
467                     against the values on and off.
468
469       $endif This command, as seen in the previous example, terminates an $if
470              command.
471
472       $else  Commands in this branch of the $if directive are executed if the
473              test fails.
474
475       $include
476              This  directive takes a single filename as an argument and reads
477              commands and bindings from that file.  For example, the  follow‐
478              ing directive would read /etc/inputrc:
479
480              $include  /etc/inputrc
481

SEARCHING

483       Readline  provides  commands  for searching through the command history
484       for lines containing a specified string.  There are two  search  modes:
485       incremental and non-incremental.
486
487       Incremental  searches  begin  before  the  user has finished typing the
488       search string.  As each character of the search string is typed,  read‐
489       line displays the next entry from the history matching the string typed
490       so far.  An incremental search requires  only  as  many  characters  as
491       needed  to  find  the desired history entry.  To search backward in the
492       history for a particular string, type C-r.  Typing C-s searches forward
493       through  the  history.   The  characters  present  in  the value of the
494       isearch-terminators variable  are  used  to  terminate  an  incremental
495       search.   If that variable has not been assigned a value the Escape and
496       C-J characters will terminate an incremental search.  C-G will abort an
497       incremental  search  and restore the original line.  When the search is
498       terminated, the history entry containing the search string becomes  the
499       current line.
500
501       To  find other matching entries in the history list, type C-s or C-r as
502       appropriate.  This will search backward or forward in the  history  for
503       the  next  line matching the search string typed so far.  Any other key
504       sequence bound to a readline command will terminate the search and exe‐
505       cute  that  command.  For instance, a newline will terminate the search
506       and accept the line, thereby executing the  command  from  the  history
507       list.  A movement command will terminate the search, make the last line
508       found the current line, and begin editing.
509
510       Non-incremental searches read the entire search string before  starting
511       to  search  for matching history lines.  The search string may be typed
512       by the user or be part of the contents of the current line.
513

EDITING COMMANDS

515       The following is a list of the names of the commands  and  the  default
516       key sequences to which they are bound.  Command names without an accom‐
517       panying key sequence are unbound by default.
518
519       In the following descriptions, point refers to the current cursor posi‐
520       tion,  and  mark refers to a cursor position saved by the set-mark com‐
521       mand.  The text between the point and mark is referred to  as  the  re‐
522       gion.
523
524   Commands for Moving
525       beginning-of-line (C-a)
526              Move to the start of the current line.
527       end-of-line (C-e)
528              Move to the end of the line.
529       forward-char (C-f)
530              Move forward a character.
531       backward-char (C-b)
532              Move back a character.
533       forward-word (M-f)
534              Move forward to the end of the next word.  Words are composed of
535              alphanumeric characters (letters and digits).
536       backward-word (M-b)
537              Move back to the start of the current or previous  word.   Words
538              are composed of alphanumeric characters (letters and digits).
539       previous-screen-line
540              Attempt  to move point to the same physical screen column on the
541              previous physical screen line. This will not  have  the  desired
542              effect  if  the current Readline line does not take up more than
543              one physical line or if point is not greater than the length  of
544              the prompt plus the screen width.
545       next-screen-line
546              Attempt  to move point to the same physical screen column on the
547              next physical screen line. This will not have the desired effect
548              if  the  current  Readline  line  does not take up more than one
549              physical line or if the length of the current Readline  line  is
550              not greater than the length of the prompt plus the screen width.
551       clear-display (M-C-l)
552              Clear  the  screen  and,  if possible, the terminal's scrollback
553              buffer, then redraw the current line, leaving the  current  line
554              at the top of the screen.
555       clear-screen (C-l)
556              Clear the screen, then redraw the current line, leaving the cur‐
557              rent line at the top of the screen.  With an  argument,  refresh
558              the current line without clearing the screen.
559       redraw-current-line
560              Refresh the current line.
561
562   Commands for Manipulating the History
563       accept-line (Newline, Return)
564              Accept the line regardless of where the cursor is.  If this line
565              is non-empty, it may be added to the history list for future re‐
566              call  with  add_history().   If  the  line is a modified history
567              line, the history line is restored to its original state.
568       previous-history (C-p)
569              Fetch the previous command from the history list, moving back in
570              the list.
571       next-history (C-n)
572              Fetch  the next command from the history list, moving forward in
573              the list.
574       beginning-of-history (M-<)
575              Move to the first line in the history.
576       end-of-history (M->)
577              Move to the end of the input history, i.e., the  line  currently
578              being entered.
579       reverse-search-history (C-r)
580              Search  backward  starting  at  the current line and moving `up'
581              through the  history  as  necessary.   This  is  an  incremental
582              search.
583       forward-search-history (C-s)
584              Search  forward  starting  at the current line and moving `down'
585              through the  history  as  necessary.   This  is  an  incremental
586              search.
587       non-incremental-reverse-search-history (M-p)
588              Search backward through the history starting at the current line
589              using a non-incremental search for  a  string  supplied  by  the
590              user.
591       non-incremental-forward-search-history (M-n)
592              Search  forward  through  the  history  using  a non-incremental
593              search for a string supplied by the user.
594       history-search-backward
595              Search backward through the history for the string of characters
596              between the start of the current line and the current cursor po‐
597              sition (the point).  The search string must match at the  begin‐
598              ning of a history line.  This is a non-incremental search.
599       history-search-forward
600              Search  forward through the history for the string of characters
601              between the start of the current line and the point.  The search
602              string must match at the beginning of a history line.  This is a
603              non-incremental search.
604       history-substring-search-backward
605              Search backward through the history for the string of characters
606              between the start of the current line and the current cursor po‐
607              sition (the point).  The search string may match anywhere  in  a
608              history line.  This is a non-incremental search.
609       history-substring-search-forward
610              Search  forward through the history for the string of characters
611              between the start of the current line and the point.  The search
612              string  may match anywhere in a history line.  This is a non-in‐
613              cremental search.
614       yank-nth-arg (M-C-y)
615              Insert the first argument to the previous command  (usually  the
616              second word on the previous line) at point.  With an argument n,
617              insert the nth word from the previous command (the words in  the
618              previous  command  begin  with word 0).  A negative argument in‐
619              serts the nth word from the end of the previous  command.   Once
620              the  argument n is computed, the argument is extracted as if the
621              "!n" history expansion had been specified.
622       yank-last-arg (M-., M-_)
623              Insert the last argument to the previous command (the last  word
624              of the previous history entry).  With a numeric argument, behave
625              exactly like yank-nth-arg.  Successive  calls  to  yank-last-arg
626              move  back through the history list, inserting the last word (or
627              the word specified by the argument to the first  call)  of  each
628              line in turn.  Any numeric argument supplied to these successive
629              calls determines the direction to move through the  history.   A
630              negative  argument  switches  the  direction through the history
631              (back or forward).  The history expansion facilities are used to
632              extract  the last argument, as if the "!$" history expansion had
633              been specified.
634       operate-and-get-next (C-o)
635              Accept the current line for return to the calling application as
636              if  a newline had been entered, and fetch the next line relative
637              to the current line from the history for editing.  A numeric ar‐
638              gument,  if supplied, specifies the history entry to use instead
639              of the current line.
640
641   Commands for Changing Text
642       end-of-file (usually C-d)
643              The character indicating end-of-file as  set,  for  example,  by
644              ``stty''.   If  this character is read when there are no charac‐
645              ters on the line, and point is at the  beginning  of  the  line,
646              Readline interprets it as the end of input and returns EOF.
647       delete-char (C-d)
648              Delete the character at point.  If this function is bound to the
649              same character as the tty EOF character, as C-d commonly is, see
650              above for the effects.
651       backward-delete-char (Rubout)
652              Delete  the  character  behind the cursor.  When given a numeric
653              argument, save the deleted text on the kill ring.
654       forward-backward-delete-char
655              Delete the character under the cursor, unless the cursor  is  at
656              the end of the line, in which case the character behind the cur‐
657              sor is deleted.
658       quoted-insert (C-q, C-v)
659              Add the next character that you type to the line verbatim.  This
660              is how to insert characters like C-q, for example.
661       tab-insert (M-TAB)
662              Insert a tab character.
663       self-insert (a, b, A, 1, !, ...)
664              Insert the character typed.
665       transpose-chars (C-t)
666              Drag  the  character  before point forward over the character at
667              point, moving point forward as well.  If point is at the end  of
668              the  line, then this transposes the two characters before point.
669              Negative arguments have no effect.
670       transpose-words (M-t)
671              Drag the word before point past the  word  after  point,  moving
672              point  over  that  word  as well.  If point is at the end of the
673              line, this transposes the last two words on the line.
674       upcase-word (M-u)
675              Uppercase the current (or following) word.  With a negative  ar‐
676              gument, uppercase the previous word, but do not move point.
677       downcase-word (M-l)
678              Lowercase  the current (or following) word.  With a negative ar‐
679              gument, lowercase the previous word, but do not move point.
680       capitalize-word (M-c)
681              Capitalize the current (or following) word.  With a negative ar‐
682              gument, capitalize the previous word, but do not move point.
683       overwrite-mode
684              Toggle  overwrite mode.  With an explicit positive numeric argu‐
685              ment, switches to overwrite mode.  With an explicit non-positive
686              numeric argument, switches to insert mode.  This command affects
687              only emacs mode; vi mode does overwrite differently.  Each  call
688              to readline() starts in insert mode.  In overwrite mode, charac‐
689              ters bound to self-insert replace the text at point rather  than
690              pushing  the  text  to  the  right.   Characters  bound to back‐
691              ward-delete-char replace  the  character  before  point  with  a
692              space.  By default, this command is unbound.
693
694   Killing and Yanking
695       kill-line (C-k)
696              Kill the text from point to the end of the line.
697       backward-kill-line (C-x Rubout)
698              Kill backward to the beginning of the line.
699       unix-line-discard (C-u)
700              Kill  backward  from  point  to  the beginning of the line.  The
701              killed text is saved on the kill-ring.
702       kill-whole-line
703              Kill all characters on the current line, no matter  where  point
704              is.
705       kill-word (M-d)
706              Kill  from  point  the  end  of  the current word, or if between
707              words, to the end of the next word.   Word  boundaries  are  the
708              same as those used by forward-word.
709       backward-kill-word (M-Rubout)
710              Kill  the  word  behind  point.  Word boundaries are the same as
711              those used by backward-word.
712       unix-word-rubout (C-w)
713              Kill the word behind point, using white space as a  word  bound‐
714              ary.  The killed text is saved on the kill-ring.
715       unix-filename-rubout
716              Kill  the  word  behind  point,  using white space and the slash
717              character as the word boundaries.  The killed text is  saved  on
718              the kill-ring.
719       delete-horizontal-space (M-\)
720              Delete all spaces and tabs around point.
721       kill-region
722              Kill  the  text  between  the point and mark (saved cursor posi‐
723              tion).  This text is referred to as the region.
724       copy-region-as-kill
725              Copy the text in the region to the kill buffer.
726       copy-backward-word
727              Copy the word before point to the kill buffer.  The word  bound‐
728              aries are the same as backward-word.
729       copy-forward-word
730              Copy  the  word  following  point  to the kill buffer.  The word
731              boundaries are the same as forward-word.
732       yank (C-y)
733              Yank the top of the kill ring into the buffer at point.
734       yank-pop (M-y)
735              Rotate the kill ring, and yank the new top.  Only works  follow‐
736              ing yank or yank-pop.
737
738   Numeric Arguments
739       digit-argument (M-0, M-1, ..., M--)
740              Add  this digit to the argument already accumulating, or start a
741              new argument.  M-- starts a negative argument.
742       universal-argument
743              This is another way to specify an argument.  If this command  is
744              followed  by one or more digits, optionally with a leading minus
745              sign, those digits define the argument.  If the command is  fol‐
746              lowed by digits, executing universal-argument again ends the nu‐
747              meric argument, but is otherwise ignored.  As a special case, if
748              this command is immediately followed by a character that is nei‐
749              ther a digit or minus sign, the argument count for the next com‐
750              mand  is  multiplied  by  four.  The argument count is initially
751              one, so executing this function the first time makes  the  argu‐
752              ment count four, a second time makes the argument count sixteen,
753              and so on.
754
755   Completing
756       complete (TAB)
757              Attempt to perform completion on the text before point.  The ac‐
758              tual  completion  performed  is application-specific.  Bash, for
759              instance, attempts completion treating the text  as  a  variable
760              (if  the  text begins with $), username (if the text begins with
761              ~), hostname (if the text begins with @), or command  (including
762              aliases  and  functions)  in  turn.  If none of these produces a
763              match, filename completion is  attempted.   Gdb,  on  the  other
764              hand,  allows completion of program functions and variables, and
765              only attempts filename completion under certain circumstances.
766       possible-completions (M-?)
767              List the possible completions of the text  before  point.   When
768              displaying completions, readline sets the number of columns used
769              for display to the value of completion-display-width, the  value
770              of  the  environment  variable  COLUMNS, or the screen width, in
771              that order.
772       insert-completions (M-*)
773              Insert all completions of the text before point that would  have
774              been generated by possible-completions.
775       menu-complete
776              Similar  to complete, but replaces the word to be completed with
777              a single match from the list of possible completions.   Repeated
778              execution  of  menu-complete  steps through the list of possible
779              completions, inserting each match in turn.  At the  end  of  the
780              list of completions, the bell is rung (subject to the setting of
781              bell-style) and the original text is restored.  An argument of n
782              moves n positions forward in the list of matches; a negative ar‐
783              gument may be used to move backward through the list.  This com‐
784              mand is intended to be bound to TAB, but is unbound by default.
785       menu-complete-backward
786              Identical  to menu-complete, but moves backward through the list
787              of possible completions, as if menu-complete had  been  given  a
788              negative argument.  This command is unbound by default.
789       delete-char-or-list
790              Deletes  the  character under the cursor if not at the beginning
791              or end of the line (like delete-char).  If at  the  end  of  the
792              line, behaves identically to possible-completions.
793
794   Keyboard Macros
795       start-kbd-macro (C-x ()
796              Begin  saving  the  characters  typed  into the current keyboard
797              macro.
798       end-kbd-macro (C-x ))
799              Stop saving the characters typed into the current keyboard macro
800              and store the definition.
801       call-last-kbd-macro (C-x e)
802              Re-execute  the last keyboard macro defined, by making the char‐
803              acters in the macro appear as if typed at the keyboard.
804       print-last-kbd-macro ()
805              Print the last keyboard macro defined in a format  suitable  for
806              the inputrc file.
807
808   Miscellaneous
809       re-read-init-file (C-x C-r)
810              Read  in  the  contents of the inputrc file, and incorporate any
811              bindings or variable assignments found there.
812       abort (C-g)
813              Abort the current editing command and ring the  terminal's  bell
814              (subject to the setting of bell-style).
815       do-lowercase-version (M-A, M-B, M-x, ...)
816              If  the  metafied character x is uppercase, run the command that
817              is bound to the corresponding metafied lowercase character.  The
818              behavior is undefined if x is already lowercase.
819       prefix-meta (ESC)
820              Metafy the next character typed.  ESC f is equivalent to Meta-f.
821       undo (C-_, C-x C-u)
822              Incremental undo, separately remembered for each line.
823       revert-line (M-r)
824              Undo  all changes made to this line.  This is like executing the
825              undo command enough times to return  the  line  to  its  initial
826              state.
827       tilde-expand (M-&)
828              Perform tilde expansion on the current word.
829       set-mark (C-@, M-<space>)
830              Set  the  mark to the point.  If a numeric argument is supplied,
831              the mark is set to that position.
832       exchange-point-and-mark (C-x C-x)
833              Swap the point with the mark.  The current  cursor  position  is
834              set  to the saved position, and the old cursor position is saved
835              as the mark.
836       character-search (C-])
837              A character is read and point is moved to the next occurrence of
838              that  character.   A negative count searches for previous occur‐
839              rences.
840       character-search-backward (M-C-])
841              A character is read and point is moved to  the  previous  occur‐
842              rence  of  that character.  A negative count searches for subse‐
843              quent occurrences.
844       skip-csi-sequence
845              Read enough characters to consume a multi-key sequence  such  as
846              those  defined for keys like Home and End.  Such sequences begin
847              with a Control Sequence Indicator (CSI), usually ESC-[.  If this
848              sequence  is  bound  to "\[", keys producing such sequences will
849              have no effect unless explicitly bound to  a  readline  command,
850              instead  of  inserting stray characters into the editing buffer.
851              This is unbound by default, but usually bound to ESC-[.
852       insert-comment (M-#)
853              Without a numeric argument,  the  value  of  the  readline  com‐
854              ment-begin  variable is inserted at the beginning of the current
855              line.  If a numeric argument is supplied, this command acts as a
856              toggle:  if  the  characters at the beginning of the line do not
857              match the value of comment-begin, the value is inserted,  other‐
858              wise the characters in comment-begin are deleted from the begin‐
859              ning of the line.  In either case, the line is accepted as if  a
860              newline  had  been  typed.   The  default value of comment-begin
861              makes the current line a shell comment.  If a  numeric  argument
862              causes the comment character to be removed, the line will be ex‐
863              ecuted by the shell.
864       dump-functions
865              Print all of the functions and their key bindings to  the  read‐
866              line output stream.  If a numeric argument is supplied, the out‐
867              put is formatted in such a way that it can be made  part  of  an
868              inputrc file.
869       dump-variables
870              Print  all  of  the  settable  variables and their values to the
871              readline output stream.  If a numeric argument is supplied,  the
872              output is formatted in such a way that it can be made part of an
873              inputrc file.
874       dump-macros
875              Print all of the readline key sequences bound to macros and  the
876              strings  they  output.   If  a numeric argument is supplied, the
877              output is formatted in such a way that it can be made part of an
878              inputrc file.
879       emacs-editing-mode (C-e)
880              When  in  vi command mode, this causes a switch to emacs editing
881              mode.
882       vi-editing-mode (M-C-j)
883              When in emacs editing mode, this causes a switch to  vi  editing
884              mode.
885

DEFAULT KEY BINDINGS

887       The  following is a list of the default emacs and vi bindings.  Charac‐
888       ters with the eighth bit set are written as M-<character>, and are  re‐
889       ferred  to  as metafied characters.  The printable ASCII characters not
890       mentioned in the list of emacs  standard  bindings  are  bound  to  the
891       self-insert  function,  which just inserts the given character into the
892       input line.  In vi insertion mode, all characters not specifically men‐
893       tioned are bound to self-insert.  Characters assigned to signal genera‐
894       tion by stty(1) or the terminal driver, such as C-Z or C-C, retain that
895       function.   Upper  and  lower case metafied characters are bound to the
896       same function in the emacs mode meta keymap.  The remaining  characters
897       are  unbound,  which  causes  readline to ring the bell (subject to the
898       setting of the bell-style variable).
899
900   Emacs Mode
901             Emacs Standard bindings
902
903             "C-@"  set-mark
904             "C-A"  beginning-of-line
905             "C-B"  backward-char
906             "C-D"  delete-char
907             "C-E"  end-of-line
908             "C-F"  forward-char
909             "C-G"  abort
910             "C-H"  backward-delete-char
911             "C-I"  complete
912             "C-J"  accept-line
913             "C-K"  kill-line
914             "C-L"  clear-screen
915             "C-M"  accept-line
916             "C-N"  next-history
917             "C-P"  previous-history
918             "C-Q"  quoted-insert
919             "C-R"  reverse-search-history
920             "C-S"  forward-search-history
921             "C-T"  transpose-chars
922             "C-U"  unix-line-discard
923             "C-V"  quoted-insert
924             "C-W"  unix-word-rubout
925             "C-Y"  yank
926             "C-]"  character-search
927             "C-_"  undo
928             " " to "/"  self-insert
929             "0"  to "9"  self-insert
930             ":"  to "~"  self-insert
931             "C-?"  backward-delete-char
932
933             Emacs Meta bindings
934
935             "M-C-G"  abort
936             "M-C-H"  backward-kill-word
937             "M-C-I"  tab-insert
938             "M-C-J"  vi-editing-mode
939             "M-C-L"  clear-display
940             "M-C-M"  vi-editing-mode
941             "M-C-R"  revert-line
942             "M-C-Y"  yank-nth-arg
943             "M-C-["  complete
944             "M-C-]"  character-search-backward
945             "M-space"  set-mark
946             "M-#"  insert-comment
947             "M-&"  tilde-expand
948             "M-*"  insert-completions
949             "M--"  digit-argument
950             "M-."  yank-last-arg
951             "M-0"  digit-argument
952             "M-1"  digit-argument
953             "M-2"  digit-argument
954             "M-3"  digit-argument
955             "M-4"  digit-argument
956             "M-5"  digit-argument
957             "M-6"  digit-argument
958             "M-7"  digit-argument
959             "M-8"  digit-argument
960             "M-9"  digit-argument
961             "M-<"  beginning-of-history
962             "M-="  possible-completions
963             "M->"  end-of-history
964             "M-?"  possible-completions
965             "M-B"  backward-word
966             "M-C"  capitalize-word
967             "M-D"  kill-word
968             "M-F"  forward-word
969             "M-L"  downcase-word
970             "M-N"  non-incremental-forward-search-history
971             "M-P"  non-incremental-reverse-search-history
972             "M-R"  revert-line
973             "M-T"  transpose-words
974             "M-U"  upcase-word
975             "M-Y"  yank-pop
976             "M-\"  delete-horizontal-space
977             "M-~"  tilde-expand
978             "M-C-?"  backward-kill-word
979             "M-_"  yank-last-arg
980
981             Emacs Control-X bindings
982
983             "C-XC-G"  abort
984             "C-XC-R"  re-read-init-file
985             "C-XC-U"  undo
986             "C-XC-X"  exchange-point-and-mark
987             "C-X("  start-kbd-macro
988             "C-X)"  end-kbd-macro
989             "C-XE"  call-last-kbd-macro
990             "C-XC-?"  backward-kill-line
991
992
993   VI Mode bindings
994             VI Insert Mode functions
995
996             "C-D"  vi-eof-maybe
997             "C-H"  backward-delete-char
998             "C-I"  complete
999             "C-J"  accept-line
1000             "C-M"  accept-line
1001             "C-R"  reverse-search-history
1002             "C-S"  forward-search-history
1003             "C-T"  transpose-chars
1004             "C-U"  unix-line-discard
1005             "C-V"  quoted-insert
1006             "C-W"  unix-word-rubout
1007             "C-Y"  yank
1008             "C-["  vi-movement-mode
1009             "C-_"  undo
1010             " " to "~"  self-insert
1011             "C-?"  backward-delete-char
1012
1013             VI Command Mode functions
1014
1015             "C-D"  vi-eof-maybe
1016             "C-E"  emacs-editing-mode
1017             "C-G"  abort
1018             "C-H"  backward-char
1019             "C-J"  accept-line
1020             "C-K"  kill-line
1021             "C-L"  clear-screen
1022             "C-M"  accept-line
1023             "C-N"  next-history
1024             "C-P"  previous-history
1025             "C-Q"  quoted-insert
1026             "C-R"  reverse-search-history
1027             "C-S"  forward-search-history
1028             "C-T"  transpose-chars
1029             "C-U"  unix-line-discard
1030             "C-V"  quoted-insert
1031             "C-W"  unix-word-rubout
1032             "C-Y"  yank
1033             "C-_"  vi-undo
1034             " "  forward-char
1035             "#"  insert-comment
1036             "$"  end-of-line
1037             "%"  vi-match
1038             "&"  vi-tilde-expand
1039             "*"  vi-complete
1040             "+"  next-history
1041             ","  vi-char-search
1042             "-"  previous-history
1043             "."  vi-redo
1044             "/"  vi-search
1045             "0"  beginning-of-line
1046             "1" to "9"  vi-arg-digit
1047             ";"  vi-char-search
1048             "="  vi-complete
1049             "?"  vi-search
1050             "A"  vi-append-eol
1051             "B"  vi-prev-word
1052             "C"  vi-change-to
1053             "D"  vi-delete-to
1054             "E"  vi-end-word
1055             "F"  vi-char-search
1056             "G"  vi-fetch-history
1057             "I"  vi-insert-beg
1058             "N"  vi-search-again
1059             "P"  vi-put
1060             "R"  vi-replace
1061             "S"  vi-subst
1062             "T"  vi-char-search
1063             "U"  revert-line
1064             "W"  vi-next-word
1065             "X"  backward-delete-char
1066             "Y"  vi-yank-to
1067             "\"  vi-complete
1068             "^"  vi-first-print
1069             "_"  vi-yank-arg
1070             "`"  vi-goto-mark
1071             "a"  vi-append-mode
1072             "b"  vi-prev-word
1073             "c"  vi-change-to
1074             "d"  vi-delete-to
1075             "e"  vi-end-word
1076             "f"  vi-char-search
1077             "h"  backward-char
1078             "i"  vi-insertion-mode
1079             "j"  next-history
1080             "k"  prev-history
1081             "l"  forward-char
1082             "m"  vi-set-mark
1083             "n"  vi-search-again
1084             "p"  vi-put
1085             "r"  vi-change-char
1086             "s"  vi-subst
1087             "t"  vi-char-search
1088             "u"  vi-undo
1089             "w"  vi-next-word
1090             "x"  vi-delete
1091             "y"  vi-yank-to
1092             "|"  vi-column
1093             "~"  vi-change-case
1094

SEE ALSO

1096       The Gnu Readline Library, Brian Fox and Chet Ramey
1097       The Gnu History Library, Brian Fox and Chet Ramey
1098       bash(1)
1099

FILES

1101       ~/.inputrc
1102              Individual readline initialization file
1103

AUTHORS

1105       Brian Fox, Free Software Foundation
1106       bfox@gnu.org
1107
1108       Chet Ramey, Case Western Reserve University
1109       chet.ramey@case.edu
1110

BUG REPORTS

1112       If you find a bug in readline, you should report it.   But  first,  you
1113       should  make  sure  that it really is a bug, and that it appears in the
1114       latest version of the readline library that you have.
1115
1116       Once you have determined that a bug actually exists, mail a bug  report
1117       to  bug-readline@gnu.org.   If  you have a fix, you are welcome to mail
1118       that as well!  Suggestions  and  `philosophical'  bug  reports  may  be
1119       mailed  to  bug-readline@gnu.org  or  posted  to  the  Usenet newsgroup
1120       gnu.bash.bug.
1121
1122       Comments and bug reports concerning this manual page should be directed
1123       to chet.ramey@case.edu.
1124

BUGS

1126       It's too big and too slow.
1127
1128
1129
1130GNU Readline 8.1                2020 October 29                    READLINE(3)
Impressum