xref: /openbsd-src/gnu/lib/libreadline/doc/rluser.texinfo (revision af70c2df780099dcdde93deaba1af49686a47bbf)
11acd27e7Smillert@comment %**start of header (This is for running Texinfo on a region.)
21acd27e7Smillert@setfilename rluser.info
31acd27e7Smillert@comment %**end of header (This is for running Texinfo on a region.)
41acd27e7Smillert@setchapternewpage odd
51acd27e7Smillert
61acd27e7Smillert@ignore
71acd27e7SmillertThis file documents the end user interface to the GNU command line
81acd27e7Smillertediting features.  It is to be an appendix to manuals for programs which
91acd27e7Smillertuse these features.  There is a document entitled "readline.texinfo"
101acd27e7Smillertwhich contains both end-user and programmer documentation for the
111acd27e7SmillertGNU Readline Library.
121acd27e7Smillert
13*af70c2dfSkettenisCopyright (C) 1988-2002 Free Software Foundation, Inc.
141acd27e7Smillert
151acd27e7SmillertAuthored by Brian Fox and Chet Ramey.
161acd27e7Smillert
171acd27e7SmillertPermission is granted to process this file through Tex and print the
181acd27e7Smillertresults, provided the printed document carries copying permission notice
191acd27e7Smillertidentical to this one except for the removal of this paragraph (this
201acd27e7Smillertparagraph not being relevant to the printed manual).
211acd27e7Smillert
221acd27e7SmillertPermission is granted to make and distribute verbatim copies of this manual
231acd27e7Smillertprovided the copyright notice and this permission notice are preserved on
241acd27e7Smillertall copies.
251acd27e7Smillert
261acd27e7SmillertPermission is granted to copy and distribute modified versions of this
271acd27e7Smillertmanual under the conditions for verbatim copying, provided also that the
281acd27e7SmillertGNU Copyright statement is available to the distributee, and provided that
291acd27e7Smillertthe entire resulting derived work is distributed under the terms of a
301acd27e7Smillertpermission notice identical to this one.
311acd27e7Smillert
321acd27e7SmillertPermission is granted to copy and distribute translations of this manual
331acd27e7Smillertinto another language, under the above conditions for modified versions.
341acd27e7Smillert@end ignore
351acd27e7Smillert
361acd27e7Smillert@comment If you are including this manual as an appendix, then set the
371acd27e7Smillert@comment variable readline-appendix.
381acd27e7Smillert
391acd27e7Smillert@ifclear BashFeatures
401acd27e7Smillert@defcodeindex bt
411acd27e7Smillert@end ifclear
421acd27e7Smillert
431acd27e7Smillert@node Command Line Editing
441acd27e7Smillert@chapter Command Line Editing
451acd27e7Smillert
461acd27e7SmillertThis chapter describes the basic features of the @sc{gnu}
471acd27e7Smillertcommand line editing interface.
481acd27e7Smillert@ifset BashFeatures
491acd27e7SmillertCommand line editing is provided by the Readline library, which is
501acd27e7Smillertused by several different programs, including Bash.
511acd27e7Smillert@end ifset
521acd27e7Smillert
531acd27e7Smillert@menu
541acd27e7Smillert* Introduction and Notation::	Notation used in this text.
551acd27e7Smillert* Readline Interaction::	The minimum set of commands for editing a line.
561acd27e7Smillert* Readline Init File::		Customizing Readline from a user's view.
571acd27e7Smillert* Bindable Readline Commands::	A description of most of the Readline commands
581acd27e7Smillert				available for binding
591acd27e7Smillert* Readline vi Mode::		A short description of how to make Readline
601acd27e7Smillert				behave like the vi editor.
611acd27e7Smillert@ifset BashFeatures
621acd27e7Smillert* Programmable Completion::	How to specify the possible completions for
631acd27e7Smillert				a specific command.
641acd27e7Smillert* Programmable Completion Builtins::	Builtin commands to specify how to
651acd27e7Smillert				complete arguments for a particular command.
661acd27e7Smillert@end ifset
671acd27e7Smillert@end menu
681acd27e7Smillert
691acd27e7Smillert@node Introduction and Notation
701acd27e7Smillert@section Introduction to Line Editing
711acd27e7Smillert
721acd27e7SmillertThe following paragraphs describe the notation used to represent
731acd27e7Smillertkeystrokes.
741acd27e7Smillert
75*af70c2dfSkettenisThe text @kbd{C-k} is read as `Control-K' and describes the character
761acd27e7Smillertproduced when the @key{k} key is pressed while the Control key
771acd27e7Smillertis depressed.
781acd27e7Smillert
79*af70c2dfSkettenisThe text @kbd{M-k} is read as `Meta-K' and describes the character
801acd27e7Smillertproduced when the Meta key (if you have one) is depressed, and the @key{k}
811acd27e7Smillertkey is pressed.
821acd27e7SmillertThe Meta key is labeled @key{ALT} on many keyboards.
831acd27e7SmillertOn keyboards with two keys labeled @key{ALT} (usually to either side of
841acd27e7Smillertthe space bar), the @key{ALT} on the left side is generally set to
851acd27e7Smillertwork as a Meta key.
861acd27e7SmillertThe @key{ALT} key on the right may also be configured to work as a
871acd27e7SmillertMeta key or may be configured as some other modifier, such as a
881acd27e7SmillertCompose key for typing accented characters.
891acd27e7Smillert
901acd27e7SmillertIf you do not have a Meta or @key{ALT} key, or another key working as
911acd27e7Smillerta Meta key, the identical keystroke can be generated by typing @key{ESC}
92*af70c2dfSkettenis@emph{first}, and then typing @key{k}.
931acd27e7SmillertEither process is known as @dfn{metafying} the @key{k} key.
941acd27e7Smillert
95*af70c2dfSkettenisThe text @kbd{M-C-k} is read as `Meta-Control-k' and describes the
96*af70c2dfSkettenischaracter produced by @dfn{metafying} @kbd{C-k}.
971acd27e7Smillert
981acd27e7SmillertIn addition, several keys have their own names.  Specifically,
991acd27e7Smillert@key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all
1001acd27e7Smillertstand for themselves when seen in this text, or in an init file
1011acd27e7Smillert(@pxref{Readline Init File}).
1021acd27e7SmillertIf your keyboard lacks a @key{LFD} key, typing @key{C-j} will
1031acd27e7Smillertproduce the desired character.
1041acd27e7SmillertThe @key{RET} key may be labeled @key{Return} or @key{Enter} on
1051acd27e7Smillertsome keyboards.
1061acd27e7Smillert
1071acd27e7Smillert@node Readline Interaction
1081acd27e7Smillert@section Readline Interaction
1091acd27e7Smillert@cindex interaction, readline
1101acd27e7Smillert
1111acd27e7SmillertOften during an interactive session you type in a long line of text,
1121acd27e7Smillertonly to notice that the first word on the line is misspelled.  The
1131acd27e7SmillertReadline library gives you a set of commands for manipulating the text
1141acd27e7Smillertas you type it in, allowing you to just fix your typo, and not forcing
1151acd27e7Smillertyou to retype the majority of the line.  Using these editing commands,
1161acd27e7Smillertyou move the cursor to the place that needs correction, and delete or
1171acd27e7Smillertinsert the text of the corrections.  Then, when you are satisfied with
118*af70c2dfSkettenisthe line, you simply press @key{RET}.  You do not have to be at the
119*af70c2dfSkettenisend of the line to press @key{RET}; the entire line is accepted
1201acd27e7Smillertregardless of the location of the cursor within the line.
1211acd27e7Smillert
1221acd27e7Smillert@menu
1231acd27e7Smillert* Readline Bare Essentials::	The least you need to know about Readline.
1241acd27e7Smillert* Readline Movement Commands::	Moving about the input line.
1251acd27e7Smillert* Readline Killing Commands::	How to delete text, and how to get it back!
1261acd27e7Smillert* Readline Arguments::		Giving numeric arguments to commands.
1271acd27e7Smillert* Searching::			Searching through previous lines.
1281acd27e7Smillert@end menu
1291acd27e7Smillert
1301acd27e7Smillert@node Readline Bare Essentials
1311acd27e7Smillert@subsection Readline Bare Essentials
1321acd27e7Smillert@cindex notation, readline
1331acd27e7Smillert@cindex command editing
1341acd27e7Smillert@cindex editing command lines
1351acd27e7Smillert
1361acd27e7SmillertIn order to enter characters into the line, simply type them.  The typed
1371acd27e7Smillertcharacter appears where the cursor was, and then the cursor moves one
1381acd27e7Smillertspace to the right.  If you mistype a character, you can use your
1391acd27e7Smillerterase character to back up and delete the mistyped character.
1401acd27e7Smillert
1411acd27e7SmillertSometimes you may mistype a character, and
1421acd27e7Smillertnot notice the error until you have typed several other characters.  In
143*af70c2dfSkettenisthat case, you can type @kbd{C-b} to move the cursor to the left, and then
1441acd27e7Smillertcorrect your mistake.  Afterwards, you can move the cursor to the right
145*af70c2dfSketteniswith @kbd{C-f}.
1461acd27e7Smillert
1471acd27e7SmillertWhen you add text in the middle of a line, you will notice that characters
1481acd27e7Smillertto the right of the cursor are `pushed over' to make room for the text
1491acd27e7Smillertthat you have inserted.  Likewise, when you delete text behind the cursor,
1501acd27e7Smillertcharacters to the right of the cursor are `pulled back' to fill in the
1511acd27e7Smillertblank space created by the removal of the text.  A list of the bare
1521acd27e7Smillertessentials for editing the text of an input line follows.
1531acd27e7Smillert
1541acd27e7Smillert@table @asis
155*af70c2dfSkettenis@item @kbd{C-b}
1561acd27e7SmillertMove back one character.
157*af70c2dfSkettenis@item @kbd{C-f}
1581acd27e7SmillertMove forward one character.
1591acd27e7Smillert@item @key{DEL} or @key{Backspace}
1601acd27e7SmillertDelete the character to the left of the cursor.
161*af70c2dfSkettenis@item @kbd{C-d}
1621acd27e7SmillertDelete the character underneath the cursor.
1631acd27e7Smillert@item @w{Printing characters}
1641acd27e7SmillertInsert the character into the line at the cursor.
165*af70c2dfSkettenis@item @kbd{C-_} or @kbd{C-x C-u}
1661acd27e7SmillertUndo the last editing command.  You can undo all the way back to an
1671acd27e7Smillertempty line.
1681acd27e7Smillert@end table
1691acd27e7Smillert
1701acd27e7Smillert@noindent
1711acd27e7Smillert(Depending on your configuration, the @key{Backspace} key be set to
1721acd27e7Smillertdelete the character to the left of the cursor and the @key{DEL} key set
173*af70c2dfSkettenisto delete the character underneath the cursor, like @kbd{C-d}, rather
1741acd27e7Smillertthan the character to the left of the cursor.)
1751acd27e7Smillert
1761acd27e7Smillert@node Readline Movement Commands
1771acd27e7Smillert@subsection Readline Movement Commands
1781acd27e7Smillert
1791acd27e7Smillert
1801acd27e7SmillertThe above table describes the most basic keystrokes that you need
1811acd27e7Smillertin order to do editing of the input line.  For your convenience, many
182*af70c2dfSkettenisother commands have been added in addition to @kbd{C-b}, @kbd{C-f},
183*af70c2dfSkettenis@kbd{C-d}, and @key{DEL}.  Here are some commands for moving more rapidly
1841acd27e7Smillertabout the line.
1851acd27e7Smillert
186*af70c2dfSkettenis@table @kbd
1871acd27e7Smillert@item C-a
1881acd27e7SmillertMove to the start of the line.
1891acd27e7Smillert@item C-e
1901acd27e7SmillertMove to the end of the line.
1911acd27e7Smillert@item M-f
1921acd27e7SmillertMove forward a word, where a word is composed of letters and digits.
1931acd27e7Smillert@item M-b
1941acd27e7SmillertMove backward a word.
1951acd27e7Smillert@item C-l
1961acd27e7SmillertClear the screen, reprinting the current line at the top.
1971acd27e7Smillert@end table
1981acd27e7Smillert
199*af70c2dfSkettenisNotice how @kbd{C-f} moves forward a character, while @kbd{M-f} moves
2001acd27e7Smillertforward a word.  It is a loose convention that control keystrokes
2011acd27e7Smillertoperate on characters while meta keystrokes operate on words.
2021acd27e7Smillert
2031acd27e7Smillert@node Readline Killing Commands
2041acd27e7Smillert@subsection Readline Killing Commands
2051acd27e7Smillert
2061acd27e7Smillert@cindex killing text
2071acd27e7Smillert@cindex yanking text
2081acd27e7Smillert
2091acd27e7Smillert@dfn{Killing} text means to delete the text from the line, but to save
2101acd27e7Smillertit away for later use, usually by @dfn{yanking} (re-inserting)
2111acd27e7Smillertit back into the line.
2121acd27e7Smillert(`Cut' and `paste' are more recent jargon for `kill' and `yank'.)
2131acd27e7Smillert
2141acd27e7SmillertIf the description for a command says that it `kills' text, then you can
2151acd27e7Smillertbe sure that you can get the text back in a different (or the same)
2161acd27e7Smillertplace later.
2171acd27e7Smillert
2181acd27e7SmillertWhen you use a kill command, the text is saved in a @dfn{kill-ring}.
2191acd27e7SmillertAny number of consecutive kills save all of the killed text together, so
2201acd27e7Smillertthat when you yank it back, you get it all.  The kill
2211acd27e7Smillertring is not line specific; the text that you killed on a previously
2221acd27e7Smillerttyped line is available to be yanked back later, when you are typing
2231acd27e7Smillertanother line.
2241acd27e7Smillert@cindex kill ring
2251acd27e7Smillert
2261acd27e7SmillertHere is the list of commands for killing text.
2271acd27e7Smillert
228*af70c2dfSkettenis@table @kbd
2291acd27e7Smillert@item C-k
2301acd27e7SmillertKill the text from the current cursor position to the end of the line.
2311acd27e7Smillert
2321acd27e7Smillert@item M-d
2331acd27e7SmillertKill from the cursor to the end of the current word, or, if between
2341acd27e7Smillertwords, to the end of the next word.
235*af70c2dfSkettenisWord boundaries are the same as those used by @kbd{M-f}.
2361acd27e7Smillert
237*af70c2dfSkettenis@item M-@key{DEL}
238*af70c2dfSkettenisKill from the cursor the start of the current word, or, if between
2391acd27e7Smillertwords, to the start of the previous word.
240*af70c2dfSkettenisWord boundaries are the same as those used by @kbd{M-b}.
2411acd27e7Smillert
2421acd27e7Smillert@item C-w
2431acd27e7SmillertKill from the cursor to the previous whitespace.  This is different than
244*af70c2dfSkettenis@kbd{M-@key{DEL}} because the word boundaries differ.
2451acd27e7Smillert
2461acd27e7Smillert@end table
2471acd27e7Smillert
2481acd27e7SmillertHere is how to @dfn{yank} the text back into the line.  Yanking
2491acd27e7Smillertmeans to copy the most-recently-killed text from the kill buffer.
2501acd27e7Smillert
251*af70c2dfSkettenis@table @kbd
2521acd27e7Smillert@item C-y
2531acd27e7SmillertYank the most recently killed text back into the buffer at the cursor.
2541acd27e7Smillert
2551acd27e7Smillert@item M-y
2561acd27e7SmillertRotate the kill-ring, and yank the new top.  You can only do this if
257*af70c2dfSkettenisthe prior command is @kbd{C-y} or @kbd{M-y}.
2581acd27e7Smillert@end table
2591acd27e7Smillert
2601acd27e7Smillert@node Readline Arguments
2611acd27e7Smillert@subsection Readline Arguments
2621acd27e7Smillert
2631acd27e7SmillertYou can pass numeric arguments to Readline commands.  Sometimes the
2641acd27e7Smillertargument acts as a repeat count, other times it is the @i{sign} of the
2651acd27e7Smillertargument that is significant.  If you pass a negative argument to a
2661acd27e7Smillertcommand which normally acts in a forward direction, that command will
2671acd27e7Smillertact in a backward direction.  For example, to kill text back to the
2681acd27e7Smillertstart of the line, you might type @samp{M-- C-k}.
2691acd27e7Smillert
2701acd27e7SmillertThe general way to pass numeric arguments to a command is to type meta
2711acd27e7Smillertdigits before the command.  If the first `digit' typed is a minus
2721acd27e7Smillertsign (@samp{-}), then the sign of the argument will be negative.  Once
2731acd27e7Smillertyou have typed one meta digit to get the argument started, you can type
2741acd27e7Smillertthe remainder of the digits, and then the command.  For example, to give
275*af70c2dfSkettenisthe @kbd{C-d} command an argument of 10, you could type @samp{M-1 0 C-d},
276*af70c2dfSketteniswhich will delete the next ten characters on the input line.
2771acd27e7Smillert
2781acd27e7Smillert@node Searching
2791acd27e7Smillert@subsection Searching for Commands in the History
2801acd27e7Smillert
2811acd27e7SmillertReadline provides commands for searching through the command history
2821acd27e7Smillert@ifset BashFeatures
2831acd27e7Smillert(@pxref{Bash History Facilities})
2841acd27e7Smillert@end ifset
2851acd27e7Smillertfor lines containing a specified string.
286*af70c2dfSkettenisThere are two search modes:  @dfn{incremental} and @dfn{non-incremental}.
2871acd27e7Smillert
2881acd27e7SmillertIncremental searches begin before the user has finished typing the
2891acd27e7Smillertsearch string.
2901acd27e7SmillertAs each character of the search string is typed, Readline displays
2911acd27e7Smillertthe next entry from the history matching the string typed so far.
2921acd27e7SmillertAn incremental search requires only as many characters as needed to
2931acd27e7Smillertfind the desired history entry.
2941acd27e7SmillertTo search backward in the history for a particular string, type
295*af70c2dfSkettenis@kbd{C-r}.  Typing @kbd{C-s} searches forward through the history.
2961acd27e7SmillertThe characters present in the value of the @code{isearch-terminators} variable
2971acd27e7Smillertare used to terminate an incremental search.
2981acd27e7SmillertIf that variable has not been assigned a value, the @key{ESC} and
299*af70c2dfSkettenis@kbd{C-J} characters will terminate an incremental search.
300*af70c2dfSkettenis@kbd{C-g} will abort an incremental search and restore the original line.
3011acd27e7SmillertWhen the search is terminated, the history entry containing the
3021acd27e7Smillertsearch string becomes the current line.
3031acd27e7Smillert
304*af70c2dfSkettenisTo find other matching entries in the history list, type @kbd{C-r} or
305*af70c2dfSkettenis@kbd{C-s} as appropriate.
3061acd27e7SmillertThis will search backward or forward in the history for the next
3071acd27e7Smillertentry matching the search string typed so far.
3081acd27e7SmillertAny other key sequence bound to a Readline command will terminate
3091acd27e7Smillertthe search and execute that command.
3101acd27e7SmillertFor instance, a @key{RET} will terminate the search and accept
3111acd27e7Smillertthe line, thereby executing the command from the history list.
312*af70c2dfSkettenisA movement command will terminate the search, make the last line found
313*af70c2dfSkettenisthe current line, and begin editing.
314*af70c2dfSkettenis
315*af70c2dfSkettenisReadline remembers the last incremental search string.  If two
316*af70c2dfSkettenis@kbd{C-r}s are typed without any intervening characters defining a new
317*af70c2dfSkettenissearch string, any remembered search string is used.
3181acd27e7Smillert
3191acd27e7SmillertNon-incremental searches read the entire search string before starting
3201acd27e7Smillertto search for matching history lines.  The search string may be
3211acd27e7Smillerttyped by the user or be part of the contents of the current line.
3221acd27e7Smillert
3231acd27e7Smillert@node Readline Init File
3241acd27e7Smillert@section Readline Init File
3251acd27e7Smillert@cindex initialization file, readline
3261acd27e7Smillert
3271acd27e7SmillertAlthough the Readline library comes with a set of Emacs-like
3281acd27e7Smillertkeybindings installed by default, it is possible to use a different set
3291acd27e7Smillertof keybindings.
3301acd27e7SmillertAny user can customize programs that use Readline by putting
3311acd27e7Smillertcommands in an @dfn{inputrc} file, conventionally in his home directory.
3321acd27e7SmillertThe name of this
3331acd27e7Smillert@ifset BashFeatures
334*af70c2dfSkettenisfile is taken from the value of the shell variable @env{INPUTRC}.  If
3351acd27e7Smillert@end ifset
3361acd27e7Smillert@ifclear BashFeatures
337*af70c2dfSkettenisfile is taken from the value of the environment variable @env{INPUTRC}.  If
3381acd27e7Smillert@end ifclear
3391acd27e7Smillertthat variable is unset, the default is @file{~/.inputrc}.
3401acd27e7Smillert
3411acd27e7SmillertWhen a program which uses the Readline library starts up, the
3421acd27e7Smillertinit file is read, and the key bindings are set.
3431acd27e7Smillert
3441acd27e7SmillertIn addition, the @code{C-x C-r} command re-reads this init file, thus
3451acd27e7Smillertincorporating any changes that you might have made to it.
3461acd27e7Smillert
3471acd27e7Smillert@menu
3481acd27e7Smillert* Readline Init File Syntax::	Syntax for the commands in the inputrc file.
3491acd27e7Smillert
3501acd27e7Smillert* Conditional Init Constructs::	Conditional key bindings in the inputrc file.
3511acd27e7Smillert
3521acd27e7Smillert* Sample Init File::		An example inputrc file.
3531acd27e7Smillert@end menu
3541acd27e7Smillert
3551acd27e7Smillert@node Readline Init File Syntax
3561acd27e7Smillert@subsection Readline Init File Syntax
3571acd27e7Smillert
3581acd27e7SmillertThere are only a few basic constructs allowed in the
3591acd27e7SmillertReadline init file.  Blank lines are ignored.
3601acd27e7SmillertLines beginning with a @samp{#} are comments.
3611acd27e7SmillertLines beginning with a @samp{$} indicate conditional
3621acd27e7Smillertconstructs (@pxref{Conditional Init Constructs}).  Other lines
3631acd27e7Smillertdenote variable settings and key bindings.
3641acd27e7Smillert
3651acd27e7Smillert@table @asis
3661acd27e7Smillert@item Variable Settings
3671acd27e7SmillertYou can modify the run-time behavior of Readline by
3681acd27e7Smillertaltering the values of variables in Readline
369*af70c2dfSkettenisusing the @code{set} command within the init file.
370*af70c2dfSkettenisThe syntax is simple:
371*af70c2dfSkettenis
372*af70c2dfSkettenis@example
373*af70c2dfSkettenisset @var{variable} @var{value}
374*af70c2dfSkettenis@end example
375*af70c2dfSkettenis
376*af70c2dfSkettenis@noindent
377*af70c2dfSkettenisHere, for example, is how to
3781acd27e7Smillertchange from the default Emacs-like key binding to use
3791acd27e7Smillert@code{vi} line editing commands:
3801acd27e7Smillert
3811acd27e7Smillert@example
3821acd27e7Smillertset editing-mode vi
3831acd27e7Smillert@end example
3841acd27e7Smillert
385*af70c2dfSkettenisVariable names and values, where appropriate, are recognized without regard
386*af70c2dfSkettenisto case.
387*af70c2dfSkettenis
3881acd27e7Smillert@ifset BashFeatures
3891acd27e7SmillertThe @w{@code{bind -V}} command lists the current Readline variable names
3901acd27e7Smillertand values.  @xref{Bash Builtins}.
3911acd27e7Smillert@end ifset
3921acd27e7Smillert
3931acd27e7SmillertA great deal of run-time behavior is changeable with the following
3941acd27e7Smillertvariables.
3951acd27e7Smillert
396*af70c2dfSkettenis@cindex variables, readline
3971acd27e7Smillert@table @code
3981acd27e7Smillert
3991acd27e7Smillert@item bell-style
4001acd27e7Smillert@vindex bell-style
4011acd27e7SmillertControls what happens when Readline wants to ring the terminal bell.
4021acd27e7SmillertIf set to @samp{none}, Readline never rings the bell.  If set to
4031acd27e7Smillert@samp{visible}, Readline uses a visible bell if one is available.
4041acd27e7SmillertIf set to @samp{audible} (the default), Readline attempts to ring
4051acd27e7Smillertthe terminal's bell.
4061acd27e7Smillert
4071acd27e7Smillert@item comment-begin
4081acd27e7Smillert@vindex comment-begin
4091acd27e7SmillertThe string to insert at the beginning of the line when the
4101acd27e7Smillert@code{insert-comment} command is executed.  The default value
4111acd27e7Smillertis @code{"#"}.
4121acd27e7Smillert
4131acd27e7Smillert@item completion-ignore-case
4141acd27e7SmillertIf set to @samp{on}, Readline performs filename matching and completion
4151acd27e7Smillertin a case-insensitive fashion.
4161acd27e7SmillertThe default value is @samp{off}.
4171acd27e7Smillert
4181acd27e7Smillert@item completion-query-items
4191acd27e7Smillert@vindex completion-query-items
4201acd27e7SmillertThe number of possible completions that determines when the user is
4211acd27e7Smillertasked whether he wants to see the list of possibilities.  If the
4221acd27e7Smillertnumber of possible completions is greater than this value,
4231acd27e7SmillertReadline will ask the user whether or not he wishes to view
424*af70c2dfSkettenisthem; otherwise, they are simply listed.
425*af70c2dfSkettenisThis variable must be set to an integer value greater than or equal to 0.
426*af70c2dfSkettenisThe default limit is @code{100}.
4271acd27e7Smillert
4281acd27e7Smillert@item convert-meta
4291acd27e7Smillert@vindex convert-meta
4301acd27e7SmillertIf set to @samp{on}, Readline will convert characters with the
431*af70c2dfSketteniseighth bit set to an @sc{ascii} key sequence by stripping the eighth
4321acd27e7Smillertbit and prefixing an @key{ESC} character, converting them to a
4331acd27e7Smillertmeta-prefixed key sequence.  The default value is @samp{on}.
4341acd27e7Smillert
4351acd27e7Smillert@item disable-completion
4361acd27e7Smillert@vindex disable-completion
4371acd27e7SmillertIf set to @samp{On}, Readline will inhibit word completion.
4381acd27e7SmillertCompletion  characters will be inserted into the line as if they had
4391acd27e7Smillertbeen mapped to @code{self-insert}.  The default is @samp{off}.
4401acd27e7Smillert
4411acd27e7Smillert@item editing-mode
4421acd27e7Smillert@vindex editing-mode
4431acd27e7SmillertThe @code{editing-mode} variable controls which default set of
4441acd27e7Smillertkey bindings is used.  By default, Readline starts up in Emacs editing
4451acd27e7Smillertmode, where the keystrokes are most similar to Emacs.  This variable can be
4461acd27e7Smillertset to either @samp{emacs} or @samp{vi}.
4471acd27e7Smillert
4481acd27e7Smillert@item enable-keypad
4491acd27e7Smillert@vindex enable-keypad
4501acd27e7SmillertWhen set to @samp{on}, Readline will try to enable the application
4511acd27e7Smillertkeypad when it is called.  Some systems need this to enable the
4521acd27e7Smillertarrow keys.  The default is @samp{off}.
4531acd27e7Smillert
4541acd27e7Smillert@item expand-tilde
4551acd27e7Smillert@vindex expand-tilde
4561acd27e7SmillertIf set to @samp{on}, tilde expansion is performed when Readline
4571acd27e7Smillertattempts word completion.  The default is @samp{off}.
4581acd27e7Smillert
459*af70c2dfSkettenis@vindex history-preserve-point
460*af70c2dfSkettenisIf set to @samp{on}, the history code attempts to place point at the
461*af70c2dfSkettenissame location on each history line retrived with @code{previous-history}
462*af70c2dfSkettenisor @code{next-history}.
463*af70c2dfSkettenis
4641acd27e7Smillert@item horizontal-scroll-mode
4651acd27e7Smillert@vindex horizontal-scroll-mode
4661acd27e7SmillertThis variable can be set to either @samp{on} or @samp{off}.  Setting it
4671acd27e7Smillertto @samp{on} means that the text of the lines being edited will scroll
4681acd27e7Smillerthorizontally on a single screen line when they are longer than the width
4691acd27e7Smillertof the screen, instead of wrapping onto a new screen line.  By default,
4701acd27e7Smillertthis variable is set to @samp{off}.
4711acd27e7Smillert
4721acd27e7Smillert@item input-meta
4731acd27e7Smillert@vindex input-meta
4741acd27e7Smillert@vindex meta-flag
4751acd27e7SmillertIf set to @samp{on}, Readline will enable eight-bit input (it
476*af70c2dfSketteniswill not clear the eighth bit in the characters it reads),
4771acd27e7Smillertregardless of what the terminal claims it can support.  The
4781acd27e7Smillertdefault value is @samp{off}.  The name @code{meta-flag} is a
4791acd27e7Smillertsynonym for this variable.
4801acd27e7Smillert
4811acd27e7Smillert@item isearch-terminators
4821acd27e7Smillert@vindex isearch-terminators
4831acd27e7SmillertThe string of characters that should terminate an incremental search without
4841acd27e7Smillertsubsequently executing the character as a command (@pxref{Searching}).
4851acd27e7SmillertIf this variable has not been given a value, the characters @key{ESC} and
486*af70c2dfSkettenis@kbd{C-J} will terminate an incremental search.
4871acd27e7Smillert
4881acd27e7Smillert@item keymap
4891acd27e7Smillert@vindex keymap
4901acd27e7SmillertSets Readline's idea of the current keymap for key binding commands.
4911acd27e7SmillertAcceptable @code{keymap} names are
4921acd27e7Smillert@code{emacs},
4931acd27e7Smillert@code{emacs-standard},
4941acd27e7Smillert@code{emacs-meta},
4951acd27e7Smillert@code{emacs-ctlx},
4961acd27e7Smillert@code{vi},
497*af70c2dfSkettenis@code{vi-move},
4981acd27e7Smillert@code{vi-command}, and
4991acd27e7Smillert@code{vi-insert}.
5001acd27e7Smillert@code{vi} is equivalent to @code{vi-command}; @code{emacs} is
5011acd27e7Smillertequivalent to @code{emacs-standard}.  The default value is @code{emacs}.
5021acd27e7SmillertThe value of the @code{editing-mode} variable also affects the
5031acd27e7Smillertdefault keymap.
5041acd27e7Smillert
5051acd27e7Smillert@item mark-directories
5061acd27e7SmillertIf set to @samp{on}, completed directory names have a slash
5071acd27e7Smillertappended.  The default is @samp{on}.
5081acd27e7Smillert
5091acd27e7Smillert@item mark-modified-lines
5101acd27e7Smillert@vindex mark-modified-lines
5111acd27e7SmillertThis variable, when set to @samp{on}, causes Readline to display an
5121acd27e7Smillertasterisk (@samp{*}) at the start of history lines which have been modified.
5131acd27e7SmillertThis variable is @samp{off} by default.
5141acd27e7Smillert
515*af70c2dfSkettenis@item mark-symlinked-directories
516*af70c2dfSkettenis@vindex mark-symlinked-directories
517*af70c2dfSkettenisIf set to @samp{on}, completed names which are symbolic links
518*af70c2dfSkettenisto directories have a slash appended (subject to the value of
519*af70c2dfSkettenis@code{mark-directories}).
520*af70c2dfSkettenisThe default is @samp{off}.
521*af70c2dfSkettenis
522*af70c2dfSkettenis@item match-hidden-files
523*af70c2dfSkettenis@vindex match-hidden-files
524*af70c2dfSkettenisThis variable, when set to @samp{on}, causes Readline to match files whose
525*af70c2dfSkettenisnames begin with a @samp{.} (hidden files) when performing filename
526*af70c2dfSketteniscompletion, unless the leading @samp{.} is
527*af70c2dfSkettenissupplied by the user in the filename to be completed.
528*af70c2dfSkettenisThis variable is @samp{on} by default.
529*af70c2dfSkettenis
5301acd27e7Smillert@item output-meta
5311acd27e7Smillert@vindex output-meta
5321acd27e7SmillertIf set to @samp{on}, Readline will display characters with the
5331acd27e7Smillerteighth bit set directly rather than as a meta-prefixed escape
5341acd27e7Smillertsequence.  The default is @samp{off}.
5351acd27e7Smillert
536*af70c2dfSkettenis@item page-completions
537*af70c2dfSkettenis@vindex page-completions
538*af70c2dfSkettenisIf set to @samp{on}, Readline uses an internal @code{more}-like pager
539*af70c2dfSkettenisto display a screenful of possible completions at a time.
540*af70c2dfSkettenisThis variable is @samp{on} by default.
541*af70c2dfSkettenis
5421acd27e7Smillert@item print-completions-horizontally
5431acd27e7SmillertIf set to @samp{on}, Readline will display completions with matches
5441acd27e7Smillertsorted horizontally in alphabetical order, rather than down the screen.
5451acd27e7SmillertThe default is @samp{off}.
5461acd27e7Smillert
5471acd27e7Smillert@item show-all-if-ambiguous
5481acd27e7Smillert@vindex show-all-if-ambiguous
5491acd27e7SmillertThis alters the default behavior of the completion functions.  If
5501acd27e7Smillertset to @samp{on},
5511acd27e7Smillertwords which have more than one possible completion cause the
5521acd27e7Smillertmatches to be listed immediately instead of ringing the bell.
5531acd27e7SmillertThe default value is @samp{off}.
5541acd27e7Smillert
5551acd27e7Smillert@item visible-stats
5561acd27e7Smillert@vindex visible-stats
5571acd27e7SmillertIf set to @samp{on}, a character denoting a file's type
5581acd27e7Smillertis appended to the filename when listing possible
5591acd27e7Smillertcompletions.  The default is @samp{off}.
5601acd27e7Smillert
5611acd27e7Smillert@end table
5621acd27e7Smillert
5631acd27e7Smillert@item Key Bindings
5641acd27e7SmillertThe syntax for controlling key bindings in the init file is
5651acd27e7Smillertsimple.  First you need to find the name of the command that you
5661acd27e7Smillertwant to change.  The following sections contain tables of the command
5671acd27e7Smillertname, the default keybinding, if any, and a short description of what
5681acd27e7Smillertthe command does.
5691acd27e7Smillert
570*af70c2dfSkettenisOnce you know the name of the command, simply place on a line
571*af70c2dfSkettenisin the init file the name of the key
5721acd27e7Smillertyou wish to bind the command to, a colon, and then the name of the
573*af70c2dfSketteniscommand.  The name of the key
574*af70c2dfSketteniscan be expressed in different ways, depending on what you find most
575*af70c2dfSketteniscomfortable.
576*af70c2dfSkettenis
577*af70c2dfSkettenisIn addition to command names, readline allows keys to be bound
578*af70c2dfSkettenisto a string that is inserted when the key is pressed (a @var{macro}).
5791acd27e7Smillert
5801acd27e7Smillert@ifset BashFeatures
5811acd27e7SmillertThe @w{@code{bind -p}} command displays Readline function names and
5821acd27e7Smillertbindings in a format that can put directly into an initialization file.
5831acd27e7Smillert@xref{Bash Builtins}.
5841acd27e7Smillert@end ifset
5851acd27e7Smillert
5861acd27e7Smillert@table @asis
5871acd27e7Smillert@item @w{@var{keyname}: @var{function-name} or @var{macro}}
5881acd27e7Smillert@var{keyname} is the name of a key spelled out in English.  For example:
5891acd27e7Smillert@example
5901acd27e7SmillertControl-u: universal-argument
5911acd27e7SmillertMeta-Rubout: backward-kill-word
5921acd27e7SmillertControl-o: "> output"
5931acd27e7Smillert@end example
5941acd27e7Smillert
595*af70c2dfSkettenisIn the above example, @kbd{C-u} is bound to the function
596*af70c2dfSkettenis@code{universal-argument},
597*af70c2dfSkettenis@kbd{M-DEL} is bound to the function @code{backward-kill-word}, and
598*af70c2dfSkettenis@kbd{C-o} is bound to run the macro
5991acd27e7Smillertexpressed on the right hand side (that is, to insert the text
6001acd27e7Smillert@samp{> output} into the line).
6011acd27e7Smillert
602*af70c2dfSkettenisA number of symbolic character names are recognized while
603*af70c2dfSkettenisprocessing this key binding syntax:
604*af70c2dfSkettenis@var{DEL},
605*af70c2dfSkettenis@var{ESC},
606*af70c2dfSkettenis@var{ESCAPE},
607*af70c2dfSkettenis@var{LFD},
608*af70c2dfSkettenis@var{NEWLINE},
609*af70c2dfSkettenis@var{RET},
610*af70c2dfSkettenis@var{RETURN},
611*af70c2dfSkettenis@var{RUBOUT},
612*af70c2dfSkettenis@var{SPACE},
613*af70c2dfSkettenis@var{SPC},
614*af70c2dfSkettenisand
615*af70c2dfSkettenis@var{TAB}.
616*af70c2dfSkettenis
6171acd27e7Smillert@item @w{"@var{keyseq}": @var{function-name} or @var{macro}}
6181acd27e7Smillert@var{keyseq} differs from @var{keyname} above in that strings
6191acd27e7Smillertdenoting an entire key sequence can be specified, by placing
6201acd27e7Smillertthe key sequence in double quotes.  Some @sc{gnu} Emacs style key
6211acd27e7Smillertescapes can be used, as in the following example, but the
6221acd27e7Smillertspecial character names are not recognized.
6231acd27e7Smillert
6241acd27e7Smillert@example
6251acd27e7Smillert"\C-u": universal-argument
6261acd27e7Smillert"\C-x\C-r": re-read-init-file
6271acd27e7Smillert"\e[11~": "Function Key 1"
6281acd27e7Smillert@end example
6291acd27e7Smillert
630*af70c2dfSkettenisIn the above example, @kbd{C-u} is again bound to the function
6311acd27e7Smillert@code{universal-argument} (just as it was in the first example),
632*af70c2dfSkettenis@samp{@kbd{C-x} @kbd{C-r}} is bound to the function @code{re-read-init-file},
6331acd27e7Smillertand @samp{@key{ESC} @key{[} @key{1} @key{1} @key{~}} is bound to insert
6341acd27e7Smillertthe text @samp{Function Key 1}.
6351acd27e7Smillert
6361acd27e7Smillert@end table
6371acd27e7Smillert
6381acd27e7SmillertThe following @sc{gnu} Emacs style escape sequences are available when
6391acd27e7Smillertspecifying key sequences:
6401acd27e7Smillert
6411acd27e7Smillert@table @code
6421acd27e7Smillert@item @kbd{\C-}
6431acd27e7Smillertcontrol prefix
6441acd27e7Smillert@item @kbd{\M-}
6451acd27e7Smillertmeta prefix
6461acd27e7Smillert@item @kbd{\e}
6471acd27e7Smillertan escape character
6481acd27e7Smillert@item @kbd{\\}
6491acd27e7Smillertbackslash
6501acd27e7Smillert@item @kbd{\"}
6511acd27e7Smillert@key{"}, a double quotation mark
6521acd27e7Smillert@item @kbd{\'}
6531acd27e7Smillert@key{'}, a single quote or apostrophe
6541acd27e7Smillert@end table
6551acd27e7Smillert
6561acd27e7SmillertIn addition to the @sc{gnu} Emacs style escape sequences, a second
6571acd27e7Smillertset of backslash escapes is available:
6581acd27e7Smillert
6591acd27e7Smillert@table @code
6601acd27e7Smillert@item \a
6611acd27e7Smillertalert (bell)
6621acd27e7Smillert@item \b
6631acd27e7Smillertbackspace
6641acd27e7Smillert@item \d
6651acd27e7Smillertdelete
6661acd27e7Smillert@item \f
6671acd27e7Smillertform feed
6681acd27e7Smillert@item \n
6691acd27e7Smillertnewline
6701acd27e7Smillert@item \r
6711acd27e7Smillertcarriage return
6721acd27e7Smillert@item \t
6731acd27e7Smillerthorizontal tab
6741acd27e7Smillert@item \v
6751acd27e7Smillertvertical tab
6761acd27e7Smillert@item \@var{nnn}
677*af70c2dfSkettenisthe eight-bit character whose value is the octal value @var{nnn}
6781acd27e7Smillert(one to three digits)
679*af70c2dfSkettenis@item \x@var{HH}
680*af70c2dfSkettenisthe eight-bit character whose value is the hexadecimal value @var{HH}
681*af70c2dfSkettenis(one or two hex digits)
6821acd27e7Smillert@end table
6831acd27e7Smillert
6841acd27e7SmillertWhen entering the text of a macro, single or double quotes must
6851acd27e7Smillertbe used to indicate a macro definition.
6861acd27e7SmillertUnquoted text is assumed to be a function name.
6871acd27e7SmillertIn the macro body, the backslash escapes described above are expanded.
6881acd27e7SmillertBackslash will quote any other character in the macro text,
6891acd27e7Smillertincluding @samp{"} and @samp{'}.
690*af70c2dfSkettenisFor example, the following binding will make @samp{@kbd{C-x} \}
6911acd27e7Smillertinsert a single @samp{\} into the line:
6921acd27e7Smillert@example
6931acd27e7Smillert"\C-x\\": "\\"
6941acd27e7Smillert@end example
6951acd27e7Smillert
6961acd27e7Smillert@end table
6971acd27e7Smillert
6981acd27e7Smillert@node Conditional Init Constructs
6991acd27e7Smillert@subsection Conditional Init Constructs
7001acd27e7Smillert
7011acd27e7SmillertReadline implements a facility similar in spirit to the conditional
7021acd27e7Smillertcompilation features of the C preprocessor which allows key
7031acd27e7Smillertbindings and variable settings to be performed as the result
7041acd27e7Smillertof tests.  There are four parser directives used.
7051acd27e7Smillert
7061acd27e7Smillert@table @code
7071acd27e7Smillert@item $if
7081acd27e7SmillertThe @code{$if} construct allows bindings to be made based on the
7091acd27e7Smillertediting mode, the terminal being used, or the application using
7101acd27e7SmillertReadline.  The text of the test extends to the end of the line;
7111acd27e7Smillertno characters are required to isolate it.
7121acd27e7Smillert
7131acd27e7Smillert@table @code
7141acd27e7Smillert@item mode
7151acd27e7SmillertThe @code{mode=} form of the @code{$if} directive is used to test
7161acd27e7Smillertwhether Readline is in @code{emacs} or @code{vi} mode.
7171acd27e7SmillertThis may be used in conjunction
7181acd27e7Smillertwith the @samp{set keymap} command, for instance, to set bindings in
7191acd27e7Smillertthe @code{emacs-standard} and @code{emacs-ctlx} keymaps only if
7201acd27e7SmillertReadline is starting out in @code{emacs} mode.
7211acd27e7Smillert
7221acd27e7Smillert@item term
7231acd27e7SmillertThe @code{term=} form may be used to include terminal-specific
7241acd27e7Smillertkey bindings, perhaps to bind the key sequences output by the
7251acd27e7Smillertterminal's function keys.  The word on the right side of the
7261acd27e7Smillert@samp{=} is tested against both the full name of the terminal and
7271acd27e7Smillertthe portion of the terminal name before the first @samp{-}.  This
7281acd27e7Smillertallows @code{sun} to match both @code{sun} and @code{sun-cmd},
7291acd27e7Smillertfor instance.
7301acd27e7Smillert
7311acd27e7Smillert@item application
7321acd27e7SmillertThe @var{application} construct is used to include
7331acd27e7Smillertapplication-specific settings.  Each program using the Readline
734*af70c2dfSkettenislibrary sets the @var{application name}, and you can test for
735*af70c2dfSkettenisa particular value.
7361acd27e7SmillertThis could be used to bind key sequences to functions useful for
7371acd27e7Smillerta specific program.  For instance, the following command adds a
7381acd27e7Smillertkey sequence that quotes the current or previous word in Bash:
7391acd27e7Smillert@example
7401acd27e7Smillert$if Bash
7411acd27e7Smillert# Quote the current or previous word
7421acd27e7Smillert"\C-xq": "\eb\"\ef\""
7431acd27e7Smillert$endif
7441acd27e7Smillert@end example
7451acd27e7Smillert@end table
7461acd27e7Smillert
7471acd27e7Smillert@item $endif
7481acd27e7SmillertThis command, as seen in the previous example, terminates an
7491acd27e7Smillert@code{$if} command.
7501acd27e7Smillert
7511acd27e7Smillert@item $else
7521acd27e7SmillertCommands in this branch of the @code{$if} directive are executed if
7531acd27e7Smillertthe test fails.
7541acd27e7Smillert
7551acd27e7Smillert@item $include
7561acd27e7SmillertThis directive takes a single filename as an argument and reads commands
7571acd27e7Smillertand bindings from that file.
758*af70c2dfSkettenisFor example, the following directive reads from @file{/etc/inputrc}:
7591acd27e7Smillert@example
7601acd27e7Smillert$include /etc/inputrc
7611acd27e7Smillert@end example
7621acd27e7Smillert@end table
7631acd27e7Smillert
7641acd27e7Smillert@node Sample Init File
7651acd27e7Smillert@subsection Sample Init File
7661acd27e7Smillert
767*af70c2dfSkettenisHere is an example of an @var{inputrc} file.  This illustrates key
7681acd27e7Smillertbinding, variable assignment, and conditional syntax.
7691acd27e7Smillert
7701acd27e7Smillert@example
7711acd27e7Smillert@page
7721acd27e7Smillert# This file controls the behaviour of line input editing for
773*af70c2dfSkettenis# programs that use the GNU Readline library.  Existing
774*af70c2dfSkettenis# programs include FTP, Bash, and GDB.
7751acd27e7Smillert#
7761acd27e7Smillert# You can re-read the inputrc file with C-x C-r.
7771acd27e7Smillert# Lines beginning with '#' are comments.
7781acd27e7Smillert#
779*af70c2dfSkettenis# First, include any systemwide bindings and variable
780*af70c2dfSkettenis# assignments from /etc/Inputrc
7811acd27e7Smillert$include /etc/Inputrc
7821acd27e7Smillert
7831acd27e7Smillert#
7841acd27e7Smillert# Set various bindings for emacs mode.
7851acd27e7Smillert
7861acd27e7Smillertset editing-mode emacs
7871acd27e7Smillert
7881acd27e7Smillert$if mode=emacs
7891acd27e7Smillert
7901acd27e7SmillertMeta-Control-h:	backward-kill-word	Text after the function name is ignored
7911acd27e7Smillert
7921acd27e7Smillert#
7931acd27e7Smillert# Arrow keys in keypad mode
7941acd27e7Smillert#
7951acd27e7Smillert#"\M-OD":        backward-char
7961acd27e7Smillert#"\M-OC":        forward-char
7971acd27e7Smillert#"\M-OA":        previous-history
7981acd27e7Smillert#"\M-OB":        next-history
7991acd27e7Smillert#
8001acd27e7Smillert# Arrow keys in ANSI mode
8011acd27e7Smillert#
8021acd27e7Smillert"\M-[D":        backward-char
8031acd27e7Smillert"\M-[C":        forward-char
8041acd27e7Smillert"\M-[A":        previous-history
8051acd27e7Smillert"\M-[B":        next-history
8061acd27e7Smillert#
8071acd27e7Smillert# Arrow keys in 8 bit keypad mode
8081acd27e7Smillert#
8091acd27e7Smillert#"\M-\C-OD":       backward-char
8101acd27e7Smillert#"\M-\C-OC":       forward-char
8111acd27e7Smillert#"\M-\C-OA":       previous-history
8121acd27e7Smillert#"\M-\C-OB":       next-history
8131acd27e7Smillert#
8141acd27e7Smillert# Arrow keys in 8 bit ANSI mode
8151acd27e7Smillert#
8161acd27e7Smillert#"\M-\C-[D":       backward-char
8171acd27e7Smillert#"\M-\C-[C":       forward-char
8181acd27e7Smillert#"\M-\C-[A":       previous-history
8191acd27e7Smillert#"\M-\C-[B":       next-history
8201acd27e7Smillert
8211acd27e7SmillertC-q: quoted-insert
8221acd27e7Smillert
8231acd27e7Smillert$endif
8241acd27e7Smillert
8251acd27e7Smillert# An old-style binding.  This happens to be the default.
8261acd27e7SmillertTAB: complete
8271acd27e7Smillert
8281acd27e7Smillert# Macros that are convenient for shell interaction
8291acd27e7Smillert$if Bash
8301acd27e7Smillert# edit the path
8311acd27e7Smillert"\C-xp": "PATH=$@{PATH@}\e\C-e\C-a\ef\C-f"
832*af70c2dfSkettenis# prepare to type a quoted word --
833*af70c2dfSkettenis# insert open and close double quotes
8341acd27e7Smillert# and move to just after the open quote
8351acd27e7Smillert"\C-x\"": "\"\"\C-b"
836*af70c2dfSkettenis# insert a backslash (testing backslash escapes
837*af70c2dfSkettenis# in sequences and macros)
8381acd27e7Smillert"\C-x\\": "\\"
8391acd27e7Smillert# Quote the current or previous word
8401acd27e7Smillert"\C-xq": "\eb\"\ef\""
8411acd27e7Smillert# Add a binding to refresh the line, which is unbound
8421acd27e7Smillert"\C-xr": redraw-current-line
8431acd27e7Smillert# Edit variable on current line.
8441acd27e7Smillert"\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
8451acd27e7Smillert$endif
8461acd27e7Smillert
8471acd27e7Smillert# use a visible bell if one is available
8481acd27e7Smillertset bell-style visible
8491acd27e7Smillert
8501acd27e7Smillert# don't strip characters to 7 bits when reading
8511acd27e7Smillertset input-meta on
8521acd27e7Smillert
853*af70c2dfSkettenis# allow iso-latin1 characters to be inserted rather
854*af70c2dfSkettenis# than converted to prefix-meta sequences
8551acd27e7Smillertset convert-meta off
8561acd27e7Smillert
857*af70c2dfSkettenis# display characters with the eighth bit set directly
858*af70c2dfSkettenis# rather than as meta-prefixed characters
8591acd27e7Smillertset output-meta on
8601acd27e7Smillert
861*af70c2dfSkettenis# if there are more than 150 possible completions for
862*af70c2dfSkettenis# a word, ask the user if he wants to see all of them
8631acd27e7Smillertset completion-query-items 150
8641acd27e7Smillert
8651acd27e7Smillert# For FTP
8661acd27e7Smillert$if Ftp
8671acd27e7Smillert"\C-xg": "get \M-?"
8681acd27e7Smillert"\C-xt": "put \M-?"
8691acd27e7Smillert"\M-.": yank-last-arg
8701acd27e7Smillert$endif
8711acd27e7Smillert@end example
8721acd27e7Smillert
8731acd27e7Smillert@node Bindable Readline Commands
8741acd27e7Smillert@section Bindable Readline Commands
8751acd27e7Smillert
8761acd27e7Smillert@menu
8771acd27e7Smillert* Commands For Moving::		Moving about the line.
8781acd27e7Smillert* Commands For History::	Getting at previous lines.
8791acd27e7Smillert* Commands For Text::		Commands for changing text.
8801acd27e7Smillert* Commands For Killing::	Commands for killing and yanking.
8811acd27e7Smillert* Numeric Arguments::		Specifying numeric arguments, repeat counts.
8821acd27e7Smillert* Commands For Completion::	Getting Readline to do the typing for you.
8831acd27e7Smillert* Keyboard Macros::		Saving and re-executing typed characters
8841acd27e7Smillert* Miscellaneous Commands::	Other miscellaneous commands.
8851acd27e7Smillert@end menu
8861acd27e7Smillert
8871acd27e7SmillertThis section describes Readline commands that may be bound to key
8881acd27e7Smillertsequences.
8891acd27e7Smillert@ifset BashFeatures
8901acd27e7SmillertYou can list your key bindings by executing
8911acd27e7Smillert@w{@code{bind -P}} or, for a more terse format, suitable for an
8921acd27e7Smillert@var{inputrc} file, @w{@code{bind -p}}.  (@xref{Bash Builtins}.)
8931acd27e7Smillert@end ifset
8941acd27e7SmillertCommand names without an accompanying key sequence are unbound by default.
895*af70c2dfSkettenis
896*af70c2dfSkettenisIn the following descriptions, @dfn{point} refers to the current cursor
897*af70c2dfSkettenisposition, and @dfn{mark} refers to a cursor position saved by the
8981acd27e7Smillert@code{set-mark} command.
899*af70c2dfSkettenisThe text between the point and mark is referred to as the @dfn{region}.
9001acd27e7Smillert
9011acd27e7Smillert@node Commands For Moving
9021acd27e7Smillert@subsection Commands For Moving
9031acd27e7Smillert@ftable @code
9041acd27e7Smillert@item beginning-of-line (C-a)
9051acd27e7SmillertMove to the start of the current line.
9061acd27e7Smillert
9071acd27e7Smillert@item end-of-line (C-e)
9081acd27e7SmillertMove to the end of the line.
9091acd27e7Smillert
9101acd27e7Smillert@item forward-char (C-f)
9111acd27e7SmillertMove forward a character.
9121acd27e7Smillert
9131acd27e7Smillert@item backward-char (C-b)
9141acd27e7SmillertMove back a character.
9151acd27e7Smillert
9161acd27e7Smillert@item forward-word (M-f)
9171acd27e7SmillertMove forward to the end of the next word.  Words are composed of
9181acd27e7Smillertletters and digits.
9191acd27e7Smillert
9201acd27e7Smillert@item backward-word (M-b)
9211acd27e7SmillertMove back to the start of the current or previous word.  Words are
9221acd27e7Smillertcomposed of letters and digits.
9231acd27e7Smillert
9241acd27e7Smillert@item clear-screen (C-l)
9251acd27e7SmillertClear the screen and redraw the current line,
9261acd27e7Smillertleaving the current line at the top of the screen.
9271acd27e7Smillert
9281acd27e7Smillert@item redraw-current-line ()
9291acd27e7SmillertRefresh the current line.  By default, this is unbound.
9301acd27e7Smillert
9311acd27e7Smillert@end ftable
9321acd27e7Smillert
9331acd27e7Smillert@node Commands For History
9341acd27e7Smillert@subsection Commands For Manipulating The History
9351acd27e7Smillert
9361acd27e7Smillert@ftable @code
937*af70c2dfSkettenis@item accept-line (Newline or Return)
9381acd27e7Smillert@ifset BashFeatures
939*af70c2dfSkettenisAccept the line regardless of where the cursor is.
940*af70c2dfSkettenisIf this line is
9411acd27e7Smillertnon-empty, add it to the history list according to the setting of
942*af70c2dfSkettenisthe @env{HISTCONTROL} and @env{HISTIGNORE} variables.
943*af70c2dfSkettenisIf this line is a modified history line, then restore the history line
944*af70c2dfSkettenisto its original state.
9451acd27e7Smillert@end ifset
9461acd27e7Smillert@ifclear BashFeatures
947*af70c2dfSkettenisAccept the line regardless of where the cursor is.
948*af70c2dfSkettenisIf this line is
949*af70c2dfSkettenisnon-empty, it may be added to the history list for future recall with
950*af70c2dfSkettenis@code{add_history()}.
951*af70c2dfSkettenisIf this line is a modified history line, the history line is restored
952*af70c2dfSkettenisto its original state.
9531acd27e7Smillert@end ifclear
9541acd27e7Smillert
9551acd27e7Smillert@item previous-history (C-p)
956*af70c2dfSkettenisMove `back' through the history list, fetching the previous command.
9571acd27e7Smillert
9581acd27e7Smillert@item next-history (C-n)
959*af70c2dfSkettenisMove `forward' through the history list, fetching the next command.
9601acd27e7Smillert
9611acd27e7Smillert@item beginning-of-history (M-<)
9621acd27e7SmillertMove to the first line in the history.
9631acd27e7Smillert
9641acd27e7Smillert@item end-of-history (M->)
9651acd27e7SmillertMove to the end of the input history, i.e., the line currently
9661acd27e7Smillertbeing entered.
9671acd27e7Smillert
9681acd27e7Smillert@item reverse-search-history (C-r)
9691acd27e7SmillertSearch backward starting at the current line and moving `up' through
9701acd27e7Smillertthe history as necessary.  This is an incremental search.
9711acd27e7Smillert
9721acd27e7Smillert@item forward-search-history (C-s)
9731acd27e7SmillertSearch forward starting at the current line and moving `down' through
9741acd27e7Smillertthe the history as necessary.  This is an incremental search.
9751acd27e7Smillert
9761acd27e7Smillert@item non-incremental-reverse-search-history (M-p)
9771acd27e7SmillertSearch backward starting at the current line and moving `up'
9781acd27e7Smillertthrough the history as necessary using a non-incremental search
9791acd27e7Smillertfor a string supplied by the user.
9801acd27e7Smillert
9811acd27e7Smillert@item non-incremental-forward-search-history (M-n)
9821acd27e7SmillertSearch forward starting at the current line and moving `down'
9831acd27e7Smillertthrough the the history as necessary using a non-incremental search
9841acd27e7Smillertfor a string supplied by the user.
9851acd27e7Smillert
9861acd27e7Smillert@item history-search-forward ()
9871acd27e7SmillertSearch forward through the history for the string of characters
9881acd27e7Smillertbetween the start of the current line and the point.
9891acd27e7SmillertThis is a non-incremental search.
9901acd27e7SmillertBy default, this command is unbound.
9911acd27e7Smillert
9921acd27e7Smillert@item history-search-backward ()
9931acd27e7SmillertSearch backward through the history for the string of characters
9941acd27e7Smillertbetween the start of the current line and the point.  This
9951acd27e7Smillertis a non-incremental search.  By default, this command is unbound.
9961acd27e7Smillert
9971acd27e7Smillert@item yank-nth-arg (M-C-y)
9981acd27e7SmillertInsert the first argument to the previous command (usually
999*af70c2dfSkettenisthe second word on the previous line) at point.
1000*af70c2dfSkettenisWith an argument @var{n},
10011acd27e7Smillertinsert the @var{n}th word from the previous command (the words
10021acd27e7Smillertin the previous command begin with word 0).  A negative argument
10031acd27e7Smillertinserts the @var{n}th word from the end of the previous command.
10041acd27e7Smillert
1005*af70c2dfSkettenis@item yank-last-arg (M-. or M-_)
10061acd27e7SmillertInsert last argument to the previous command (the last word of the
10071acd27e7Smillertprevious history entry).  With an
10081acd27e7Smillertargument, behave exactly like @code{yank-nth-arg}.
10091acd27e7SmillertSuccessive calls to @code{yank-last-arg} move back through the history
10101acd27e7Smillertlist, inserting the last argument of each line in turn.
10111acd27e7Smillert
10121acd27e7Smillert@end ftable
10131acd27e7Smillert
10141acd27e7Smillert@node Commands For Text
10151acd27e7Smillert@subsection Commands For Changing Text
10161acd27e7Smillert
10171acd27e7Smillert@ftable @code
10181acd27e7Smillert@item delete-char (C-d)
1019*af70c2dfSkettenisDelete the character at point.  If point is at the
10201acd27e7Smillertbeginning of the line, there are no characters in the line, and
10211acd27e7Smillertthe last character typed was not bound to @code{delete-char}, then
1022*af70c2dfSkettenisreturn @sc{eof}.
10231acd27e7Smillert
10241acd27e7Smillert@item backward-delete-char (Rubout)
10251acd27e7SmillertDelete the character behind the cursor.  A numeric argument means
10261acd27e7Smillertto kill the characters instead of deleting them.
10271acd27e7Smillert
10281acd27e7Smillert@item forward-backward-delete-char ()
10291acd27e7SmillertDelete the character under the cursor, unless the cursor is at the
10301acd27e7Smillertend of the line, in which case the character behind the cursor is
10311acd27e7Smillertdeleted.  By default, this is not bound to a key.
10321acd27e7Smillert
1033*af70c2dfSkettenis@item quoted-insert (C-q or C-v)
10341acd27e7SmillertAdd the next character typed to the line verbatim.  This is
1035*af70c2dfSkettenishow to insert key sequences like @kbd{C-q}, for example.
10361acd27e7Smillert
10371acd27e7Smillert@ifclear BashFeatures
1038*af70c2dfSkettenis@item tab-insert (M-@key{TAB})
10391acd27e7SmillertInsert a tab character.
10401acd27e7Smillert@end ifclear
10411acd27e7Smillert
1042*af70c2dfSkettenis@item self-insert (a, b, A, 1, !, @dots{})
10431acd27e7SmillertInsert yourself.
10441acd27e7Smillert
10451acd27e7Smillert@item transpose-chars (C-t)
10461acd27e7SmillertDrag the character before the cursor forward over
10471acd27e7Smillertthe character at the cursor, moving the
10481acd27e7Smillertcursor forward as well.  If the insertion point
10491acd27e7Smillertis at the end of the line, then this
10501acd27e7Smillerttransposes the last two characters of the line.
10511acd27e7SmillertNegative arguments have no effect.
10521acd27e7Smillert
10531acd27e7Smillert@item transpose-words (M-t)
10541acd27e7SmillertDrag the word before point past the word after point,
10551acd27e7Smillertmoving point past that word as well.
1056*af70c2dfSkettenisIf the insertion point is at the end of the line, this transposes
1057*af70c2dfSkettenisthe last two words on the line.
10581acd27e7Smillert
10591acd27e7Smillert@item upcase-word (M-u)
10601acd27e7SmillertUppercase the current (or following) word.  With a negative argument,
10611acd27e7Smillertuppercase the previous word, but do not move the cursor.
10621acd27e7Smillert
10631acd27e7Smillert@item downcase-word (M-l)
10641acd27e7SmillertLowercase the current (or following) word.  With a negative argument,
10651acd27e7Smillertlowercase the previous word, but do not move the cursor.
10661acd27e7Smillert
10671acd27e7Smillert@item capitalize-word (M-c)
10681acd27e7SmillertCapitalize the current (or following) word.  With a negative argument,
10691acd27e7Smillertcapitalize the previous word, but do not move the cursor.
10701acd27e7Smillert
1071*af70c2dfSkettenis@item overwrite-mode ()
1072*af70c2dfSkettenisToggle overwrite mode.  With an explicit positive numeric argument,
1073*af70c2dfSkettenisswitches to overwrite mode.  With an explicit non-positive numeric
1074*af70c2dfSkettenisargument, switches to insert mode.  This command affects only
1075*af70c2dfSkettenis@code{emacs} mode; @code{vi} mode does overwrite differently.
1076*af70c2dfSkettenisEach call to @code{readline()} starts in insert mode.
1077*af70c2dfSkettenis
1078*af70c2dfSkettenisIn overwrite mode, characters bound to @code{self-insert} replace
1079*af70c2dfSkettenisthe text at point rather than pushing the text to the right.
1080*af70c2dfSkettenisCharacters bound to @code{backward-delete-char} replace the character
1081*af70c2dfSkettenisbefore point with a space.
1082*af70c2dfSkettenis
1083*af70c2dfSkettenisBy default, this command is unbound.
1084*af70c2dfSkettenis
10851acd27e7Smillert@end ftable
10861acd27e7Smillert
10871acd27e7Smillert@node Commands For Killing
10881acd27e7Smillert@subsection Killing And Yanking
10891acd27e7Smillert
10901acd27e7Smillert@ftable @code
10911acd27e7Smillert
10921acd27e7Smillert@item kill-line (C-k)
10931acd27e7SmillertKill the text from point to the end of the line.
10941acd27e7Smillert
10951acd27e7Smillert@item backward-kill-line (C-x Rubout)
10961acd27e7SmillertKill backward to the beginning of the line.
10971acd27e7Smillert
10981acd27e7Smillert@item unix-line-discard (C-u)
10991acd27e7SmillertKill backward from the cursor to the beginning of the current line.
11001acd27e7Smillert
11011acd27e7Smillert@item kill-whole-line ()
1102*af70c2dfSkettenisKill all characters on the current line, no matter where point is.
11031acd27e7SmillertBy default, this is unbound.
11041acd27e7Smillert
11051acd27e7Smillert@item kill-word (M-d)
11061acd27e7SmillertKill from point to the end of the current word, or if between
11071acd27e7Smillertwords, to the end of the next word.
11081acd27e7SmillertWord boundaries are the same as @code{forward-word}.
11091acd27e7Smillert
1110*af70c2dfSkettenis@item backward-kill-word (M-@key{DEL})
11111acd27e7SmillertKill the word behind point.
11121acd27e7SmillertWord boundaries are the same as @code{backward-word}.
11131acd27e7Smillert
11141acd27e7Smillert@item unix-word-rubout (C-w)
11151acd27e7SmillertKill the word behind point, using white space as a word boundary.
11161acd27e7SmillertThe killed text is saved on the kill-ring.
11171acd27e7Smillert
11181acd27e7Smillert@item delete-horizontal-space ()
11191acd27e7SmillertDelete all spaces and tabs around point.  By default, this is unbound.
11201acd27e7Smillert
11211acd27e7Smillert@item kill-region ()
11221acd27e7SmillertKill the text in the current region.
11231acd27e7SmillertBy default, this command is unbound.
11241acd27e7Smillert
11251acd27e7Smillert@item copy-region-as-kill ()
11261acd27e7SmillertCopy the text in the region to the kill buffer, so it can be yanked
11271acd27e7Smillertright away.  By default, this command is unbound.
11281acd27e7Smillert
11291acd27e7Smillert@item copy-backward-word ()
11301acd27e7SmillertCopy the word before point to the kill buffer.
11311acd27e7SmillertThe word boundaries are the same as @code{backward-word}.
11321acd27e7SmillertBy default, this command is unbound.
11331acd27e7Smillert
11341acd27e7Smillert@item copy-forward-word ()
11351acd27e7SmillertCopy the word following point to the kill buffer.
11361acd27e7SmillertThe word boundaries are the same as @code{forward-word}.
11371acd27e7SmillertBy default, this command is unbound.
11381acd27e7Smillert
11391acd27e7Smillert@item yank (C-y)
1140*af70c2dfSkettenisYank the top of the kill ring into the buffer at point.
11411acd27e7Smillert
11421acd27e7Smillert@item yank-pop (M-y)
11431acd27e7SmillertRotate the kill-ring, and yank the new top.  You can only do this if
1144*af70c2dfSkettenisthe prior command is @code{yank} or @code{yank-pop}.
11451acd27e7Smillert@end ftable
11461acd27e7Smillert
11471acd27e7Smillert@node Numeric Arguments
11481acd27e7Smillert@subsection Specifying Numeric Arguments
11491acd27e7Smillert@ftable @code
11501acd27e7Smillert
1151*af70c2dfSkettenis@item digit-argument (@kbd{M-0}, @kbd{M-1}, @dots{} @kbd{M--})
11521acd27e7SmillertAdd this digit to the argument already accumulating, or start a new
1153*af70c2dfSkettenisargument.  @kbd{M--} starts a negative argument.
11541acd27e7Smillert
11551acd27e7Smillert@item universal-argument ()
11561acd27e7SmillertThis is another way to specify an argument.
11571acd27e7SmillertIf this command is followed by one or more digits, optionally with a
11581acd27e7Smillertleading minus sign, those digits define the argument.
11591acd27e7SmillertIf the command is followed by digits, executing @code{universal-argument}
11601acd27e7Smillertagain ends the numeric argument, but is otherwise ignored.
11611acd27e7SmillertAs a special case, if this command is immediately followed by a
11621acd27e7Smillertcharacter that is neither a digit or minus sign, the argument count
11631acd27e7Smillertfor the next command is multiplied by four.
11641acd27e7SmillertThe argument count is initially one, so executing this function the
11651acd27e7Smillertfirst time makes the argument count four, a second time makes the
11661acd27e7Smillertargument count sixteen, and so on.
11671acd27e7SmillertBy default, this is not bound to a key.
11681acd27e7Smillert@end ftable
11691acd27e7Smillert
11701acd27e7Smillert@node Commands For Completion
11711acd27e7Smillert@subsection Letting Readline Type For You
11721acd27e7Smillert
11731acd27e7Smillert@ftable @code
1174*af70c2dfSkettenis@item complete (@key{TAB})
1175*af70c2dfSkettenisAttempt to perform completion on the text before point.
1176*af70c2dfSkettenisThe actual completion performed is application-specific.
11771acd27e7Smillert@ifset BashFeatures
11781acd27e7SmillertBash attempts completion treating the text as a variable (if the
11791acd27e7Smillerttext begins with @samp{$}), username (if the text begins with
11801acd27e7Smillert@samp{~}), hostname (if the text begins with @samp{@@}), or
11811acd27e7Smillertcommand (including aliases and functions) in turn.  If none
11821acd27e7Smillertof these produces a match, filename completion is attempted.
11831acd27e7Smillert@end ifset
1184*af70c2dfSkettenis@ifclear BashFeatures
1185*af70c2dfSkettenisThe default is filename completion.
1186*af70c2dfSkettenis@end ifclear
11871acd27e7Smillert
11881acd27e7Smillert@item possible-completions (M-?)
1189*af70c2dfSkettenisList the possible completions of the text before point.
11901acd27e7Smillert
11911acd27e7Smillert@item insert-completions (M-*)
11921acd27e7SmillertInsert all completions of the text before point that would have
11931acd27e7Smillertbeen generated by @code{possible-completions}.
11941acd27e7Smillert
11951acd27e7Smillert@item menu-complete ()
11961acd27e7SmillertSimilar to @code{complete}, but replaces the word to be completed
11971acd27e7Smillertwith a single match from the list of possible completions.
11981acd27e7SmillertRepeated execution of @code{menu-complete} steps through the list
11991acd27e7Smillertof possible completions, inserting each match in turn.
1200*af70c2dfSkettenisAt the end of the list of completions, the bell is rung
1201*af70c2dfSkettenis(subject to the setting of @code{bell-style})
1202*af70c2dfSkettenisand the original text is restored.
12031acd27e7SmillertAn argument of @var{n} moves @var{n} positions forward in the list
12041acd27e7Smillertof matches; a negative argument may be used to move backward
12051acd27e7Smillertthrough the list.
1206*af70c2dfSkettenisThis command is intended to be bound to @key{TAB}, but is unbound
12071acd27e7Smillertby default.
12081acd27e7Smillert
12091acd27e7Smillert@item delete-char-or-list ()
12101acd27e7SmillertDeletes the character under the cursor if not at the beginning or
12111acd27e7Smillertend of the line (like @code{delete-char}).
12121acd27e7SmillertIf at the end of the line, behaves identically to
12131acd27e7Smillert@code{possible-completions}.
12141acd27e7SmillertThis command is unbound by default.
12151acd27e7Smillert
12161acd27e7Smillert@ifset BashFeatures
12171acd27e7Smillert@item complete-filename (M-/)
12181acd27e7SmillertAttempt filename completion on the text before point.
12191acd27e7Smillert
12201acd27e7Smillert@item possible-filename-completions (C-x /)
12211acd27e7SmillertList the possible completions of the text before point,
12221acd27e7Smillerttreating it as a filename.
12231acd27e7Smillert
12241acd27e7Smillert@item complete-username (M-~)
12251acd27e7SmillertAttempt completion on the text before point, treating
12261acd27e7Smillertit as a username.
12271acd27e7Smillert
12281acd27e7Smillert@item possible-username-completions (C-x ~)
12291acd27e7SmillertList the possible completions of the text before point,
12301acd27e7Smillerttreating it as a username.
12311acd27e7Smillert
12321acd27e7Smillert@item complete-variable (M-$)
12331acd27e7SmillertAttempt completion on the text before point, treating
12341acd27e7Smillertit as a shell variable.
12351acd27e7Smillert
12361acd27e7Smillert@item possible-variable-completions (C-x $)
12371acd27e7SmillertList the possible completions of the text before point,
12381acd27e7Smillerttreating it as a shell variable.
12391acd27e7Smillert
12401acd27e7Smillert@item complete-hostname (M-@@)
12411acd27e7SmillertAttempt completion on the text before point, treating
12421acd27e7Smillertit as a hostname.
12431acd27e7Smillert
12441acd27e7Smillert@item possible-hostname-completions (C-x @@)
12451acd27e7SmillertList the possible completions of the text before point,
12461acd27e7Smillerttreating it as a hostname.
12471acd27e7Smillert
12481acd27e7Smillert@item complete-command (M-!)
12491acd27e7SmillertAttempt completion on the text before point, treating
12501acd27e7Smillertit as a command name.  Command completion attempts to
12511acd27e7Smillertmatch the text against aliases, reserved words, shell
12521acd27e7Smillertfunctions, shell builtins, and finally executable filenames,
12531acd27e7Smillertin that order.
12541acd27e7Smillert
12551acd27e7Smillert@item possible-command-completions (C-x !)
12561acd27e7SmillertList the possible completions of the text before point,
12571acd27e7Smillerttreating it as a command name.
12581acd27e7Smillert
1259*af70c2dfSkettenis@item dynamic-complete-history (M-@key{TAB})
12601acd27e7SmillertAttempt completion on the text before point, comparing
12611acd27e7Smillertthe text against lines from the history list for possible
12621acd27e7Smillertcompletion matches.
12631acd27e7Smillert
12641acd27e7Smillert@item complete-into-braces (M-@{)
12651acd27e7SmillertPerform filename completion and insert the list of possible completions
12661acd27e7Smillertenclosed within braces so the list is available to the shell
12671acd27e7Smillert(@pxref{Brace Expansion}).
12681acd27e7Smillert
12691acd27e7Smillert@end ifset
12701acd27e7Smillert@end ftable
12711acd27e7Smillert
12721acd27e7Smillert@node Keyboard Macros
12731acd27e7Smillert@subsection Keyboard Macros
12741acd27e7Smillert@ftable @code
12751acd27e7Smillert
12761acd27e7Smillert@item start-kbd-macro (C-x ()
12771acd27e7SmillertBegin saving the characters typed into the current keyboard macro.
12781acd27e7Smillert
12791acd27e7Smillert@item end-kbd-macro (C-x ))
12801acd27e7SmillertStop saving the characters typed into the current keyboard macro
12811acd27e7Smillertand save the definition.
12821acd27e7Smillert
12831acd27e7Smillert@item call-last-kbd-macro (C-x e)
12841acd27e7SmillertRe-execute the last keyboard macro defined, by making the characters
12851acd27e7Smillertin the macro appear as if typed at the keyboard.
12861acd27e7Smillert
12871acd27e7Smillert@end ftable
12881acd27e7Smillert
12891acd27e7Smillert@node Miscellaneous Commands
12901acd27e7Smillert@subsection Some Miscellaneous Commands
12911acd27e7Smillert@ftable @code
12921acd27e7Smillert
12931acd27e7Smillert@item re-read-init-file (C-x C-r)
12941acd27e7SmillertRead in the contents of the @var{inputrc} file, and incorporate
12951acd27e7Smillertany bindings or variable assignments found there.
12961acd27e7Smillert
12971acd27e7Smillert@item abort (C-g)
12981acd27e7SmillertAbort the current editing command and
12991acd27e7Smillertring the terminal's bell (subject to the setting of
13001acd27e7Smillert@code{bell-style}).
13011acd27e7Smillert
13021acd27e7Smillert@item do-uppercase-version (M-a, M-b, M-@var{x}, @dots{})
13031acd27e7SmillertIf the metafied character @var{x} is lowercase, run the command
13041acd27e7Smillertthat is bound to the corresponding uppercase character.
13051acd27e7Smillert
1306*af70c2dfSkettenis@item prefix-meta (@key{ESC})
1307*af70c2dfSkettenisMetafy the next character typed.  This is for keyboards
1308*af70c2dfSketteniswithout a meta key.  Typing @samp{@key{ESC} f} is equivalent to typing
1309*af70c2dfSkettenis@kbd{M-f}.
13101acd27e7Smillert
1311*af70c2dfSkettenis@item undo (C-_ or C-x C-u)
13121acd27e7SmillertIncremental undo, separately remembered for each line.
13131acd27e7Smillert
13141acd27e7Smillert@item revert-line (M-r)
13151acd27e7SmillertUndo all changes made to this line.  This is like executing the @code{undo}
13161acd27e7Smillertcommand enough times to get back to the beginning.
13171acd27e7Smillert
13181acd27e7Smillert@ifset BashFeatures
13191acd27e7Smillert@item tilde-expand (M-&)
13201acd27e7Smillert@end ifset
13211acd27e7Smillert@ifclear BashFeatures
13221acd27e7Smillert@item tilde-expand (M-~)
13231acd27e7Smillert@end ifclear
13241acd27e7SmillertPerform tilde expansion on the current word.
13251acd27e7Smillert
13261acd27e7Smillert@item set-mark (C-@@)
1327*af70c2dfSkettenisSet the mark to the point.  If a
13281acd27e7Smillertnumeric argument is supplied, the mark is set to that position.
13291acd27e7Smillert
13301acd27e7Smillert@item exchange-point-and-mark (C-x C-x)
13311acd27e7SmillertSwap the point with the mark.  The current cursor position is set to
13321acd27e7Smillertthe saved position, and the old cursor position is saved as the mark.
13331acd27e7Smillert
13341acd27e7Smillert@item character-search (C-])
13351acd27e7SmillertA character is read and point is moved to the next occurrence of that
13361acd27e7Smillertcharacter.  A negative count searches for previous occurrences.
13371acd27e7Smillert
13381acd27e7Smillert@item character-search-backward (M-C-])
13391acd27e7SmillertA character is read and point is moved to the previous occurrence
13401acd27e7Smillertof that character.  A negative count searches for subsequent
13411acd27e7Smillertoccurrences.
13421acd27e7Smillert
13431acd27e7Smillert@item insert-comment (M-#)
1344*af70c2dfSkettenisWithout a numeric argument, the value of the @code{comment-begin}
1345*af70c2dfSkettenisvariable is inserted at the beginning of the current line.
1346*af70c2dfSkettenisIf a numeric argument is supplied, this command acts as a toggle:  if
1347*af70c2dfSkettenisthe characters at the beginning of the line do not match the value
1348*af70c2dfSkettenisof @code{comment-begin}, the value is inserted, otherwise
1349*af70c2dfSkettenisthe characters in @code{comment-begin} are deleted from the beginning of
1350*af70c2dfSkettenisthe line.
1351*af70c2dfSkettenisIn either case, the line is accepted as if a newline had been typed.
13521acd27e7Smillert@ifset BashFeatures
13531acd27e7SmillertThe default value of @code{comment-begin} causes this command
13541acd27e7Smillertto make the current line a shell comment.
1355*af70c2dfSkettenisIf a numeric argument causes the comment character to be removed, the line
1356*af70c2dfSketteniswill be executed by the shell.
13571acd27e7Smillert@end ifset
13581acd27e7Smillert
13591acd27e7Smillert@item dump-functions ()
13601acd27e7SmillertPrint all of the functions and their key bindings to the
13611acd27e7SmillertReadline output stream.  If a numeric argument is supplied,
13621acd27e7Smillertthe output is formatted in such a way that it can be made part
13631acd27e7Smillertof an @var{inputrc} file.  This command is unbound by default.
13641acd27e7Smillert
13651acd27e7Smillert@item dump-variables ()
13661acd27e7SmillertPrint all of the settable variables and their values to the
13671acd27e7SmillertReadline output stream.  If a numeric argument is supplied,
13681acd27e7Smillertthe output is formatted in such a way that it can be made part
13691acd27e7Smillertof an @var{inputrc} file.  This command is unbound by default.
13701acd27e7Smillert
13711acd27e7Smillert@item dump-macros ()
13721acd27e7SmillertPrint all of the Readline key sequences bound to macros and the
1373*af70c2dfSkettenisstrings they output.  If a numeric argument is supplied,
13741acd27e7Smillertthe output is formatted in such a way that it can be made part
13751acd27e7Smillertof an @var{inputrc} file.  This command is unbound by default.
13761acd27e7Smillert
13771acd27e7Smillert@ifset BashFeatures
1378*af70c2dfSkettenis@item glob-complete-word (M-g)
1379*af70c2dfSkettenisThe word before point is treated as a pattern for pathname expansion,
1380*af70c2dfSketteniswith an asterisk implicitly appended.  This pattern is used to
1381*af70c2dfSkettenisgenerate a list of matching file names for possible completions.
1382*af70c2dfSkettenis
13831acd27e7Smillert@item glob-expand-word (C-x *)
13841acd27e7SmillertThe word before point is treated as a pattern for pathname expansion,
13851acd27e7Smillertand the list of matching file names is inserted, replacing the word.
1386*af70c2dfSkettenisIf a numeric argument is supplied, a @samp{*} is appended before
1387*af70c2dfSkettenispathname expansion.
13881acd27e7Smillert
13891acd27e7Smillert@item glob-list-expansions (C-x g)
13901acd27e7SmillertThe list of expansions that would have been generated by
13911acd27e7Smillert@code{glob-expand-word} is displayed, and the line is redrawn.
1392*af70c2dfSkettenisIf a numeric argument is supplied, a @samp{*} is appended before
1393*af70c2dfSkettenispathname expansion.
13941acd27e7Smillert
13951acd27e7Smillert@item display-shell-version (C-x C-v)
13961acd27e7SmillertDisplay version information about the current instance of Bash.
13971acd27e7Smillert
13981acd27e7Smillert@item shell-expand-line (M-C-e)
13991acd27e7SmillertExpand the line as the shell does.
14001acd27e7SmillertThis performs alias and history expansion as well as all of the shell
14011acd27e7Smillertword expansions (@pxref{Shell Expansions}).
14021acd27e7Smillert
14031acd27e7Smillert@item history-expand-line (M-^)
14041acd27e7SmillertPerform history expansion on the current line.
14051acd27e7Smillert
14061acd27e7Smillert@item magic-space ()
14071acd27e7SmillertPerform history expansion on the current line and insert a space
14081acd27e7Smillert(@pxref{History Interaction}).
14091acd27e7Smillert
14101acd27e7Smillert@item alias-expand-line ()
14111acd27e7SmillertPerform alias expansion on the current line (@pxref{Aliases}).
14121acd27e7Smillert
14131acd27e7Smillert@item history-and-alias-expand-line ()
14141acd27e7SmillertPerform history and alias expansion on the current line.
14151acd27e7Smillert
1416*af70c2dfSkettenis@item insert-last-argument (M-. or M-_)
14171acd27e7SmillertA synonym for @code{yank-last-arg}.
14181acd27e7Smillert
14191acd27e7Smillert@item operate-and-get-next (C-o)
14201acd27e7SmillertAccept the current line for execution and fetch the next line
14211acd27e7Smillertrelative to the current line from the history for editing.  Any
14221acd27e7Smillertargument is ignored.
14231acd27e7Smillert
1424*af70c2dfSkettenis@item edit-and-execute-command (C-xC-e)
1425*af70c2dfSkettenisInvoke an editor on the current command line, and execute the result as shell
1426*af70c2dfSketteniscommands.
1427*af70c2dfSkettenisBash attempts to invoke
1428*af70c2dfSkettenis@code{$FCEDIT}, @code{$EDITOR}, and @code{emacs}
1429*af70c2dfSkettenisas the editor, in that order.
14301acd27e7Smillert
14311acd27e7Smillert@end ifset
14321acd27e7Smillert
1433*af70c2dfSkettenis@ifclear BashFeatures
1434*af70c2dfSkettenis@item emacs-editing-mode (C-e)
1435*af70c2dfSkettenisWhen in @code{vi} command mode, this causes a switch to @code{emacs}
1436*af70c2dfSkettenisediting mode.
1437*af70c2dfSkettenis
1438*af70c2dfSkettenis@item vi-editing-mode (M-C-j)
1439*af70c2dfSkettenisWhen in @code{emacs} editing mode, this causes a switch to @code{vi}
1440*af70c2dfSkettenisediting mode.
1441*af70c2dfSkettenis
1442*af70c2dfSkettenis@end ifclear
1443*af70c2dfSkettenis
14441acd27e7Smillert@end ftable
14451acd27e7Smillert
14461acd27e7Smillert@node Readline vi Mode
14471acd27e7Smillert@section Readline vi Mode
14481acd27e7Smillert
14491acd27e7SmillertWhile the Readline library does not have a full set of @code{vi}
14501acd27e7Smillertediting functions, it does contain enough to allow simple editing
14511acd27e7Smillertof the line.  The Readline @code{vi} mode behaves as specified in
14524c41ea0cSmpechthe @sc{posix} 1003.2 standard.
14531acd27e7Smillert
14541acd27e7Smillert@ifset BashFeatures
14551acd27e7SmillertIn order to switch interactively between @code{emacs} and @code{vi}
14561acd27e7Smillertediting modes, use the @samp{set -o emacs} and @samp{set -o vi}
14571acd27e7Smillertcommands (@pxref{The Set Builtin}).
14581acd27e7Smillert@end ifset
14591acd27e7Smillert@ifclear BashFeatures
14601acd27e7SmillertIn order to switch interactively between @code{emacs} and @code{vi}
1461*af70c2dfSkettenisediting modes, use the command @kbd{M-C-j} (bound to emacs-editing-mode
1462*af70c2dfSketteniswhen in @code{vi} mode and to vi-editing-mode in @code{emacs} mode).
14631acd27e7Smillert@end ifclear
14641acd27e7SmillertThe Readline default is @code{emacs} mode.
14651acd27e7Smillert
14661acd27e7SmillertWhen you enter a line in @code{vi} mode, you are already placed in
14671acd27e7Smillert`insertion' mode, as if you had typed an @samp{i}.  Pressing @key{ESC}
14681acd27e7Smillertswitches you into `command' mode, where you can edit the text of the
14691acd27e7Smillertline with the standard @code{vi} movement keys, move to previous
14701acd27e7Smillerthistory lines with @samp{k} and subsequent lines with @samp{j}, and
14711acd27e7Smillertso forth.
14721acd27e7Smillert
14731acd27e7Smillert@ifset BashFeatures
14741acd27e7Smillert@node Programmable Completion
14751acd27e7Smillert@section Programmable Completion
14761acd27e7Smillert@cindex programmable completion
14771acd27e7Smillert
14781acd27e7SmillertWhen word completion is attempted for an argument to a command for
14791acd27e7Smillertwhich a completion specification (a @var{compspec}) has been defined
14801acd27e7Smillertusing the @code{complete} builtin (@pxref{Programmable Completion Builtins}),
14811acd27e7Smillertthe programmable completion facilities are invoked.
14821acd27e7Smillert
14831acd27e7SmillertFirst, the command name is identified.
14841acd27e7SmillertIf a compspec has been defined for that command, the
14851acd27e7Smillertcompspec is used to generate the list of possible completions for the word.
14861acd27e7SmillertIf the command word is a full pathname, a compspec for the full
14871acd27e7Smillertpathname is searched for first.
14881acd27e7SmillertIf no compspec is found for the full pathname, an attempt is made to
14891acd27e7Smillertfind a compspec for the portion following the final slash.
14901acd27e7Smillert
14911acd27e7SmillertOnce a compspec has been found, it is used to generate the list of
14921acd27e7Smillertmatching words.
14931acd27e7SmillertIf a compspec is not found, the default Bash completion
14941acd27e7Smillertdescribed above (@pxref{Commands For Completion}) is performed.
14951acd27e7Smillert
14961acd27e7SmillertFirst, the actions specified by the compspec are used.
14971acd27e7SmillertOnly matches which are prefixed by the word being completed are
14981acd27e7Smillertreturned.
1499*af70c2dfSkettenisWhen the @option{-f} or @option{-d} option is used for filename or
1500*af70c2dfSkettenisdirectory name completion, the shell variable @env{FIGNORE} is
15011acd27e7Smillertused to filter the matches.
1502*af70c2dfSkettenis@xref{Bash Variables}, for a description of @env{FIGNORE}.
15031acd27e7Smillert
15041acd27e7SmillertAny completions specified by a filename expansion pattern to the
1505*af70c2dfSkettenis@option{-G} option are generated next.
15061acd27e7SmillertThe words generated by the pattern need not match the word being completed.
1507*af70c2dfSkettenisThe @env{GLOBIGNORE} shell variable is not used to filter the matches,
1508*af70c2dfSkettenisbut the @env{FIGNORE} shell variable is used.
15091acd27e7Smillert
1510*af70c2dfSkettenisNext, the string specified as the argument to the @option{-W} option
15111acd27e7Smillertis considered.
1512*af70c2dfSkettenisThe string is first split using the characters in the @env{IFS}
15131acd27e7Smillertspecial variable as delimiters.
15141acd27e7SmillertShell quoting is honored.
15151acd27e7SmillertEach word is then expanded using
15161acd27e7Smillertbrace expansion, tilde expansion, parameter and variable expansion,
15171acd27e7Smillertcommand substitution, arithmetic expansion, and pathname expansion,
15181acd27e7Smillertas described above (@pxref{Shell Expansions}).
15191acd27e7SmillertThe results are split using the rules described above
15201acd27e7Smillert(@pxref{Word Splitting}).
15211acd27e7SmillertThe results of the expansion are prefix-matched against the word being
15221acd27e7Smillertcompleted, and the matching words become the possible completions.
15231acd27e7Smillert
15241acd27e7SmillertAfter these matches have been generated, any shell function or command
1525*af70c2dfSkettenisspecified with the @option{-F} and @option{-C} options is invoked.
1526*af70c2dfSkettenisWhen the command or function is invoked, the @env{COMP_LINE} and
1527*af70c2dfSkettenis@env{COMP_POINT} variables are assigned values as described above
15281acd27e7Smillert(@pxref{Bash Variables}).
1529*af70c2dfSkettenisIf a shell function is being invoked, the @env{COMP_WORDS} and
1530*af70c2dfSkettenis@env{COMP_CWORD} variables are also set.
15311acd27e7SmillertWhen the function or command is invoked, the first argument is the
15321acd27e7Smillertname of the command whose arguments are being completed, the
15331acd27e7Smillertsecond argument is the word being completed, and the third argument
15341acd27e7Smillertis the word preceding the word being completed on the current command line.
15351acd27e7SmillertNo filtering of the generated completions against the word being completed
15361acd27e7Smillertis performed; the function or command has complete freedom in generating
15371acd27e7Smillertthe matches.
15381acd27e7Smillert
1539*af70c2dfSkettenisAny function specified with @option{-F} is invoked first.
15401acd27e7SmillertThe function may use any of the shell facilities, including the
15411acd27e7Smillert@code{compgen} builtin described below
15421acd27e7Smillert(@pxref{Programmable Completion Builtins}), to generate the matches.
1543*af70c2dfSkettenisIt must put the possible completions in the @env{COMPREPLY} array
15441acd27e7Smillertvariable.
15451acd27e7Smillert
1546*af70c2dfSkettenisNext, any command specified with the @option{-C} option is invoked
15471acd27e7Smillertin an environment equivalent to command substitution.
15481acd27e7SmillertIt should print a list of completions, one per line, to
15491acd27e7Smillertthe standard output.
15501acd27e7SmillertBackslash may be used to escape a newline, if necessary.
15511acd27e7Smillert
15521acd27e7SmillertAfter all of the possible completions are generated, any filter
1553*af70c2dfSkettenisspecified with the @option{-X} option is applied to the list.
15541acd27e7SmillertThe filter is a pattern as used for pathname expansion; a @samp{&}
15551acd27e7Smillertin the pattern is replaced with the text of the word being completed.
15561acd27e7SmillertA literal @samp{&} may be escaped with a backslash; the backslash
15571acd27e7Smillertis removed before attempting a match.
15581acd27e7SmillertAny completion that matches the pattern will be removed from the list.
15591acd27e7SmillertA leading @samp{!} negates the pattern; in this case any completion
15601acd27e7Smillertnot matching the pattern will be removed.
15611acd27e7Smillert
1562*af70c2dfSkettenisFinally, any prefix and suffix specified with the @option{-P} and @option{-S}
15631acd27e7Smillertoptions are added to each member of the completion list, and the result is
15641acd27e7Smillertreturned to the Readline completion code as the list of possible
15651acd27e7Smillertcompletions.
15661acd27e7Smillert
1567*af70c2dfSkettenisIf the previously-applied actions do not generate any matches, and the
1568*af70c2dfSkettenis@option{-o dirnames} option was supplied to @code{complete} when the
1569*af70c2dfSketteniscompspec was defined, directory name completion is attempted.
1570*af70c2dfSkettenis
1571*af70c2dfSkettenisBy default, if a compspec is found, whatever it generates is returned to
1572*af70c2dfSkettenisthe completion code as the full set of possible completions.
1573*af70c2dfSkettenisThe default Bash completions are not attempted, and the Readline default
1574*af70c2dfSkettenisof filename completion is disabled.
1575*af70c2dfSkettenisIf the @option{-o default} option was supplied to @code{complete} when the
1576*af70c2dfSketteniscompspec was defined, Readline's default completion will be performed
1577*af70c2dfSkettenisif the compspec generates no matches.
1578*af70c2dfSkettenis
1579*af70c2dfSkettenisWhen a compspec indicates that directory name completion is desired,
1580*af70c2dfSkettenisthe programmable completion functions force Readline to append a slash
1581*af70c2dfSkettenisto completed names which are symbolic links to directories, subject to
1582*af70c2dfSkettenisthe value of the @var{mark-directories} Readline variable, regardless
1583*af70c2dfSkettenisof the setting of the @var{mark-symlinked-directories} Readline variable.
15841acd27e7Smillert
15851acd27e7Smillert@node Programmable Completion Builtins
15861acd27e7Smillert@section Programmable Completion Builtins
15871acd27e7Smillert@cindex completion builtins
15881acd27e7Smillert
15891acd27e7SmillertTwo builtin commands are available to manipulate the programmable completion
15901acd27e7Smillertfacilities.
15911acd27e7Smillert
15921acd27e7Smillert@table @code
15931acd27e7Smillert@item compgen
15941acd27e7Smillert@btindex compgen
15951acd27e7Smillert@example
15961acd27e7Smillert@code{compgen [@var{option}] [@var{word}]}
15971acd27e7Smillert@end example
15981acd27e7Smillert
15991acd27e7SmillertGenerate possible completion matches for @var{word} according to
16001acd27e7Smillertthe @var{option}s, which may be any option accepted by the
16011acd27e7Smillert@code{complete}
1602*af70c2dfSkettenisbuiltin with the exception of @option{-p} and @option{-r}, and write
16031acd27e7Smillertthe matches to the standard output.
1604*af70c2dfSkettenisWhen using the @option{-F} or @option{-C} options, the various shell variables
16051acd27e7Smillertset by the programmable completion facilities, while available, will not
16061acd27e7Smillerthave useful values.
16071acd27e7Smillert
16081acd27e7SmillertThe matches will be generated in the same way as if the programmable
16091acd27e7Smillertcompletion code had generated them directly from a completion specification
16101acd27e7Smillertwith the same flags.
16111acd27e7SmillertIf @var{word} is specified, only those completions matching @var{word}
16121acd27e7Smillertwill be displayed.
16131acd27e7Smillert
16141acd27e7SmillertThe return value is true unless an invalid option is supplied, or no
16151acd27e7Smillertmatches were generated.
16161acd27e7Smillert
16171acd27e7Smillert@item complete
16181acd27e7Smillert@btindex complete
16191acd27e7Smillert@example
1620*af70c2dfSkettenis@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
16211acd27e7Smillert[-P @var{prefix}] [-S @var{suffix}] [-X @var{filterpat}] [-F @var{function}]
16221acd27e7Smillert[-C @var{command}] @var{name} [@var{name} @dots{}]}
16231acd27e7Smillert@code{complete -pr [@var{name} @dots{}]}
16241acd27e7Smillert@end example
16251acd27e7Smillert
16261acd27e7SmillertSpecify how arguments to each @var{name} should be completed.
1627*af70c2dfSkettenisIf the @option{-p} option is supplied, or if no options are supplied, existing
16281acd27e7Smillertcompletion specifications are printed in a way that allows them to be
16291acd27e7Smillertreused as input.
1630*af70c2dfSkettenisThe @option{-r} option removes a completion specification for
16311acd27e7Smillerteach @var{name}, or, if no @var{name}s are supplied, all
16321acd27e7Smillertcompletion specifications.
16331acd27e7Smillert
16341acd27e7SmillertThe process of applying these completion specifications when word completion
16351acd27e7Smillertis attempted is described above (@pxref{Programmable Completion}).
16361acd27e7Smillert
16371acd27e7SmillertOther options, if specified, have the following meanings.
1638*af70c2dfSkettenisThe arguments to the @option{-G}, @option{-W}, and @option{-X} options
1639*af70c2dfSkettenis(and, if necessary, the @option{-P} and @option{-S} options)
16401acd27e7Smillertshould be quoted to protect them from expansion before the
16411acd27e7Smillert@code{complete} builtin is invoked.
16421acd27e7Smillert
1643*af70c2dfSkettenis
16441acd27e7Smillert@table @code
1645*af70c2dfSkettenis@item -o @var{comp-option}
1646*af70c2dfSkettenisThe @var{comp-option} controls several aspects of the compspec's behavior
1647*af70c2dfSkettenisbeyond the simple generation of completions.
1648*af70c2dfSkettenis@var{comp-option} may be one of:
1649*af70c2dfSkettenis
1650*af70c2dfSkettenis@table @code
1651*af70c2dfSkettenis
1652*af70c2dfSkettenis@item default
1653*af70c2dfSkettenisUse Readline's default filename completion if the compspec generates
1654*af70c2dfSkettenisno matches.
1655*af70c2dfSkettenis
1656*af70c2dfSkettenis@item dirnames
1657*af70c2dfSkettenisPerform directory name completion if the compspec generates no matches.
1658*af70c2dfSkettenis
1659*af70c2dfSkettenis@item filenames
1660*af70c2dfSkettenisTell Readline that the compspec generates filenames, so it can perform any
1661*af70c2dfSkettenisfilename\-specific processing (like adding a slash to directory names or
1662*af70c2dfSkettenissuppressing trailing spaces).  This option is intended to be used with
1663*af70c2dfSkettenisshell functions specified with @option{-F}.
1664*af70c2dfSkettenis
1665*af70c2dfSkettenis@item nospace
1666*af70c2dfSkettenisTell Readline not to append a space (the default) to words completed at
1667*af70c2dfSkettenisthe end of the line.
1668*af70c2dfSkettenis@end table
1669*af70c2dfSkettenis
16701acd27e7Smillert@item -A @var{action}
16711acd27e7SmillertThe @var{action} may be one of the following to generate a list of possible
16721acd27e7Smillertcompletions:
16731acd27e7Smillert
16741acd27e7Smillert@table @code
16751acd27e7Smillert@item alias
1676*af70c2dfSkettenisAlias names.  May also be specified as @option{-a}.
16771acd27e7Smillert
16781acd27e7Smillert@item arrayvar
16791acd27e7SmillertArray variable names.
16801acd27e7Smillert
16811acd27e7Smillert@item binding
16821acd27e7SmillertReadline key binding names (@pxref{Bindable Readline Commands}).
16831acd27e7Smillert
16841acd27e7Smillert@item builtin
1685*af70c2dfSkettenisNames of shell builtin commands.  May also be specified as @option{-b}.
16861acd27e7Smillert
16871acd27e7Smillert@item command
1688*af70c2dfSkettenisCommand names.  May also be specified as @option{-c}.
16891acd27e7Smillert
16901acd27e7Smillert@item directory
1691*af70c2dfSkettenisDirectory names.  May also be specified as @option{-d}.
16921acd27e7Smillert
16931acd27e7Smillert@item disabled
16941acd27e7SmillertNames of disabled shell builtins.
16951acd27e7Smillert
16961acd27e7Smillert@item enabled
16971acd27e7SmillertNames of enabled shell builtins.
16981acd27e7Smillert
16991acd27e7Smillert@item export
1700*af70c2dfSkettenisNames of exported shell variables.  May also be specified as @option{-e}.
17011acd27e7Smillert
17021acd27e7Smillert@item file
1703*af70c2dfSkettenisFile names.  May also be specified as @option{-f}.
17041acd27e7Smillert
17051acd27e7Smillert@item function
17061acd27e7SmillertNames of shell functions.
17071acd27e7Smillert
1708*af70c2dfSkettenis@item group
1709*af70c2dfSkettenisGroup names.  May also be specified as @option{-g}.
1710*af70c2dfSkettenis
17111acd27e7Smillert@item helptopic
17121acd27e7SmillertHelp topics as accepted by the @code{help} builtin (@pxref{Bash Builtins}).
17131acd27e7Smillert
17141acd27e7Smillert@item hostname
17151acd27e7SmillertHostnames, as taken from the file specified by the
1716*af70c2dfSkettenis@env{HOSTFILE} shell variable (@pxref{Bash Variables}).
17171acd27e7Smillert
17181acd27e7Smillert@item job
1719*af70c2dfSkettenisJob names, if job control is active.  May also be specified as @option{-j}.
17201acd27e7Smillert
17211acd27e7Smillert@item keyword
1722*af70c2dfSkettenisShell reserved words.  May also be specified as @option{-k}.
17231acd27e7Smillert
17241acd27e7Smillert@item running
17251acd27e7SmillertNames of running jobs, if job control is active.
17261acd27e7Smillert
1727*af70c2dfSkettenis@item service
1728*af70c2dfSkettenisService names.  May also be specified as @option{-s}.
1729*af70c2dfSkettenis
17301acd27e7Smillert@item setopt
1731*af70c2dfSkettenisValid arguments for the @option{-o} option to the @code{set} builtin
17321acd27e7Smillert(@pxref{The Set Builtin}).
17331acd27e7Smillert
17341acd27e7Smillert@item shopt
17351acd27e7SmillertShell option names as accepted by the @code{shopt} builtin
17361acd27e7Smillert(@pxref{Bash Builtins}).
17371acd27e7Smillert
17381acd27e7Smillert@item signal
17391acd27e7SmillertSignal names.
17401acd27e7Smillert
17411acd27e7Smillert@item stopped
17421acd27e7SmillertNames of stopped jobs, if job control is active.
17431acd27e7Smillert
17441acd27e7Smillert@item user
1745*af70c2dfSkettenisUser names.  May also be specified as @option{-u}.
17461acd27e7Smillert
17471acd27e7Smillert@item variable
1748*af70c2dfSkettenisNames of all shell variables.  May also be specified as @option{-v}.
17491acd27e7Smillert@end table
17501acd27e7Smillert
17511acd27e7Smillert@item -G @var{globpat}
17521acd27e7SmillertThe filename expansion pattern @var{globpat} is expanded to generate
17531acd27e7Smillertthe possible completions.
17541acd27e7Smillert
17551acd27e7Smillert@item -W @var{wordlist}
17561acd27e7SmillertThe @var{wordlist} is split using the characters in the
1757*af70c2dfSkettenis@env{IFS} special variable as delimiters, and each resultant word
17581acd27e7Smillertis expanded.
17591acd27e7SmillertThe possible completions are the members of the resultant list which
17601acd27e7Smillertmatch the word being completed.
17611acd27e7Smillert
17621acd27e7Smillert@item -C @var{command}
17631acd27e7Smillert@var{command} is executed in a subshell environment, and its output is
17641acd27e7Smillertused as the possible completions.
17651acd27e7Smillert
17661acd27e7Smillert@item -F @var{function}
17671acd27e7SmillertThe shell function @var{function} is executed in the current shell
17681acd27e7Smillertenvironment.
17691acd27e7SmillertWhen it finishes, the possible completions are retrieved from the value
1770*af70c2dfSkettenisof the @env{COMPREPLY} array variable.
17711acd27e7Smillert
17721acd27e7Smillert@item -X @var{filterpat}
17731acd27e7Smillert@var{filterpat} is a pattern as used for filename expansion.
17741acd27e7SmillertIt is applied to the list of possible completions generated by the
17751acd27e7Smillertpreceding options and arguments, and each completion matching
17761acd27e7Smillert@var{filterpat} is removed from the list.
17771acd27e7SmillertA leading @samp{!} in @var{filterpat} negates the pattern; in this
17781acd27e7Smillertcase, any completion not matching @var{filterpat} is removed.
17791acd27e7Smillert
17801acd27e7Smillert@item -P @var{prefix}
17811acd27e7Smillert@var{prefix} is added at the beginning of each possible completion
17821acd27e7Smillertafter all other options have been applied.
17831acd27e7Smillert
17841acd27e7Smillert@item -S @var{suffix}
17851acd27e7Smillert@var{suffix} is appended to each possible completion
17861acd27e7Smillertafter all other options have been applied.
17871acd27e7Smillert@end table
17881acd27e7Smillert
17891acd27e7SmillertThe return value is true unless an invalid option is supplied, an option
1790*af70c2dfSkettenisother than @option{-p} or @option{-r} is supplied without a @var{name}
17911acd27e7Smillertargument, an attempt is made to remove a completion specification for
17921acd27e7Smillerta @var{name} for which no specification exists, or
17931acd27e7Smillertan error occurs adding a completion specification.
17941acd27e7Smillert
17951acd27e7Smillert@end table
17961acd27e7Smillert@end ifset
1797