rluser.texi 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038
  1. @comment %**start of header (This is for running Texinfo on a region.)
  2. @setfilename rluser.info
  3. @comment %**end of header (This is for running Texinfo on a region.)
  4. @ignore
  5. This file documents the end user interface to the GNU command line
  6. editing features. It is to be an appendix to manuals for programs which
  7. use these features. There is a document entitled "readline.texinfo"
  8. which contains both end-user and programmer documentation for the
  9. GNU Readline Library.
  10. Copyright (C) 1988--2011 Free Software Foundation, Inc.
  11. Authored by Brian Fox and Chet Ramey.
  12. Permission is granted to process this file through Tex and print the
  13. results, provided the printed document carries copying permission notice
  14. identical to this one except for the removal of this paragraph (this
  15. paragraph not being relevant to the printed manual).
  16. Permission is granted to make and distribute verbatim copies of this manual
  17. provided the copyright notice and this permission notice are preserved on
  18. all copies.
  19. Permission is granted to copy and distribute modified versions of this
  20. manual under the conditions for verbatim copying, provided also that the
  21. GNU Copyright statement is available to the distributee, and provided that
  22. the entire resulting derived work is distributed under the terms of a
  23. permission notice identical to this one.
  24. Permission is granted to copy and distribute translations of this manual
  25. into another language, under the above conditions for modified versions.
  26. @end ignore
  27. @comment If you are including this manual as an appendix, then set the
  28. @comment variable readline-appendix.
  29. @ifclear BashFeatures
  30. @defcodeindex bt
  31. @end ifclear
  32. @node Command Line Editing
  33. @chapter Command Line Editing
  34. This chapter describes the basic features of the @sc{gnu}
  35. command line editing interface.
  36. @ifset BashFeatures
  37. Command line editing is provided by the Readline library, which is
  38. used by several different programs, including Bash.
  39. Command line editing is enabled by default when using an interactive shell,
  40. unless the @option{--noediting} option is supplied at shell invocation.
  41. Line editing is also used when using the @option{-e} option to the
  42. @code{read} builtin command (@pxref{Bash Builtins}).
  43. By default, the line editing commands are similar to those of Emacs.
  44. A vi-style line editing interface is also available.
  45. Line editing can be enabled at any time using the @option{-o emacs} or
  46. @option{-o vi} options to the @code{set} builtin command
  47. (@pxref{The Set Builtin}), or disabled using the @option{+o emacs} or
  48. @option{+o vi} options to @code{set}.
  49. @end ifset
  50. @menu
  51. * Introduction and Notation:: Notation used in this text.
  52. * Readline Interaction:: The minimum set of commands for editing a line.
  53. * Readline Init File:: Customizing Readline from a user's view.
  54. * Bindable Readline Commands:: A description of most of the Readline commands
  55. available for binding
  56. * Readline vi Mode:: A short description of how to make Readline
  57. behave like the vi editor.
  58. @ifset BashFeatures
  59. * Programmable Completion:: How to specify the possible completions for
  60. a specific command.
  61. * Programmable Completion Builtins:: Builtin commands to specify how to
  62. complete arguments for a particular command.
  63. @end ifset
  64. @end menu
  65. @node Introduction and Notation
  66. @section Introduction to Line Editing
  67. The following paragraphs describe the notation used to represent
  68. keystrokes.
  69. The text @kbd{C-k} is read as `Control-K' and describes the character
  70. produced when the @key{k} key is pressed while the Control key
  71. is depressed.
  72. The text @kbd{M-k} is read as `Meta-K' and describes the character
  73. produced when the Meta key (if you have one) is depressed, and the @key{k}
  74. key is pressed.
  75. The Meta key is labeled @key{ALT} on many keyboards.
  76. On keyboards with two keys labeled @key{ALT} (usually to either side of
  77. the space bar), the @key{ALT} on the left side is generally set to
  78. work as a Meta key.
  79. The @key{ALT} key on the right may also be configured to work as a
  80. Meta key or may be configured as some other modifier, such as a
  81. Compose key for typing accented characters.
  82. If you do not have a Meta or @key{ALT} key, or another key working as
  83. a Meta key, the identical keystroke can be generated by typing @key{ESC}
  84. @emph{first}, and then typing @key{k}.
  85. Either process is known as @dfn{metafying} the @key{k} key.
  86. The text @kbd{M-C-k} is read as `Meta-Control-k' and describes the
  87. character produced by @dfn{metafying} @kbd{C-k}.
  88. In addition, several keys have their own names. Specifically,
  89. @key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all
  90. stand for themselves when seen in this text, or in an init file
  91. (@pxref{Readline Init File}).
  92. If your keyboard lacks a @key{LFD} key, typing @key{C-j} will
  93. produce the desired character.
  94. The @key{RET} key may be labeled @key{Return} or @key{Enter} on
  95. some keyboards.
  96. @node Readline Interaction
  97. @section Readline Interaction
  98. @cindex interaction, readline
  99. Often during an interactive session you type in a long line of text,
  100. only to notice that the first word on the line is misspelled. The
  101. Readline library gives you a set of commands for manipulating the text
  102. as you type it in, allowing you to just fix your typo, and not forcing
  103. you to retype the majority of the line. Using these editing commands,
  104. you move the cursor to the place that needs correction, and delete or
  105. insert the text of the corrections. Then, when you are satisfied with
  106. the line, you simply press @key{RET}. You do not have to be at the
  107. end of the line to press @key{RET}; the entire line is accepted
  108. regardless of the location of the cursor within the line.
  109. @menu
  110. * Readline Bare Essentials:: The least you need to know about Readline.
  111. * Readline Movement Commands:: Moving about the input line.
  112. * Readline Killing Commands:: How to delete text, and how to get it back!
  113. * Readline Arguments:: Giving numeric arguments to commands.
  114. * Searching:: Searching through previous lines.
  115. @end menu
  116. @node Readline Bare Essentials
  117. @subsection Readline Bare Essentials
  118. @cindex notation, readline
  119. @cindex command editing
  120. @cindex editing command lines
  121. In order to enter characters into the line, simply type them. The typed
  122. character appears where the cursor was, and then the cursor moves one
  123. space to the right. If you mistype a character, you can use your
  124. erase character to back up and delete the mistyped character.
  125. Sometimes you may mistype a character, and
  126. not notice the error until you have typed several other characters. In
  127. that case, you can type @kbd{C-b} to move the cursor to the left, and then
  128. correct your mistake. Afterwards, you can move the cursor to the right
  129. with @kbd{C-f}.
  130. When you add text in the middle of a line, you will notice that characters
  131. to the right of the cursor are `pushed over' to make room for the text
  132. that you have inserted. Likewise, when you delete text behind the cursor,
  133. characters to the right of the cursor are `pulled back' to fill in the
  134. blank space created by the removal of the text. A list of the bare
  135. essentials for editing the text of an input line follows.
  136. @table @asis
  137. @item @kbd{C-b}
  138. Move back one character.
  139. @item @kbd{C-f}
  140. Move forward one character.
  141. @item @key{DEL} or @key{Backspace}
  142. Delete the character to the left of the cursor.
  143. @item @kbd{C-d}
  144. Delete the character underneath the cursor.
  145. @item @w{Printing characters}
  146. Insert the character into the line at the cursor.
  147. @item @kbd{C-_} or @kbd{C-x C-u}
  148. Undo the last editing command. You can undo all the way back to an
  149. empty line.
  150. @end table
  151. @noindent
  152. (Depending on your configuration, the @key{Backspace} key be set to
  153. delete the character to the left of the cursor and the @key{DEL} key set
  154. to delete the character underneath the cursor, like @kbd{C-d}, rather
  155. than the character to the left of the cursor.)
  156. @node Readline Movement Commands
  157. @subsection Readline Movement Commands
  158. The above table describes the most basic keystrokes that you need
  159. in order to do editing of the input line. For your convenience, many
  160. other commands have been added in addition to @kbd{C-b}, @kbd{C-f},
  161. @kbd{C-d}, and @key{DEL}. Here are some commands for moving more rapidly
  162. about the line.
  163. @table @kbd
  164. @item C-a
  165. Move to the start of the line.
  166. @item C-e
  167. Move to the end of the line.
  168. @item M-f
  169. Move forward a word, where a word is composed of letters and digits.
  170. @item M-b
  171. Move backward a word.
  172. @item C-l
  173. Clear the screen, reprinting the current line at the top.
  174. @end table
  175. Notice how @kbd{C-f} moves forward a character, while @kbd{M-f} moves
  176. forward a word. It is a loose convention that control keystrokes
  177. operate on characters while meta keystrokes operate on words.
  178. @node Readline Killing Commands
  179. @subsection Readline Killing Commands
  180. @cindex killing text
  181. @cindex yanking text
  182. @dfn{Killing} text means to delete the text from the line, but to save
  183. it away for later use, usually by @dfn{yanking} (re-inserting)
  184. it back into the line.
  185. (`Cut' and `paste' are more recent jargon for `kill' and `yank'.)
  186. If the description for a command says that it `kills' text, then you can
  187. be sure that you can get the text back in a different (or the same)
  188. place later.
  189. When you use a kill command, the text is saved in a @dfn{kill-ring}.
  190. Any number of consecutive kills save all of the killed text together, so
  191. that when you yank it back, you get it all. The kill
  192. ring is not line specific; the text that you killed on a previously
  193. typed line is available to be yanked back later, when you are typing
  194. another line.
  195. @cindex kill ring
  196. Here is the list of commands for killing text.
  197. @table @kbd
  198. @item C-k
  199. Kill the text from the current cursor position to the end of the line.
  200. @item M-d
  201. Kill from the cursor to the end of the current word, or, if between
  202. words, to the end of the next word.
  203. Word boundaries are the same as those used by @kbd{M-f}.
  204. @item M-@key{DEL}
  205. Kill from the cursor the start of the current word, or, if between
  206. words, to the start of the previous word.
  207. Word boundaries are the same as those used by @kbd{M-b}.
  208. @item C-w
  209. Kill from the cursor to the previous whitespace. This is different than
  210. @kbd{M-@key{DEL}} because the word boundaries differ.
  211. @end table
  212. Here is how to @dfn{yank} the text back into the line. Yanking
  213. means to copy the most-recently-killed text from the kill buffer.
  214. @table @kbd
  215. @item C-y
  216. Yank the most recently killed text back into the buffer at the cursor.
  217. @item M-y
  218. Rotate the kill-ring, and yank the new top. You can only do this if
  219. the prior command is @kbd{C-y} or @kbd{M-y}.
  220. @end table
  221. @node Readline Arguments
  222. @subsection Readline Arguments
  223. You can pass numeric arguments to Readline commands. Sometimes the
  224. argument acts as a repeat count, other times it is the @i{sign} of the
  225. argument that is significant. If you pass a negative argument to a
  226. command which normally acts in a forward direction, that command will
  227. act in a backward direction. For example, to kill text back to the
  228. start of the line, you might type @samp{M-- C-k}.
  229. The general way to pass numeric arguments to a command is to type meta
  230. digits before the command. If the first `digit' typed is a minus
  231. sign (@samp{-}), then the sign of the argument will be negative. Once
  232. you have typed one meta digit to get the argument started, you can type
  233. the remainder of the digits, and then the command. For example, to give
  234. the @kbd{C-d} command an argument of 10, you could type @samp{M-1 0 C-d},
  235. which will delete the next ten characters on the input line.
  236. @node Searching
  237. @subsection Searching for Commands in the History
  238. Readline provides commands for searching through the command history
  239. @ifset BashFeatures
  240. (@pxref{Bash History Facilities})
  241. @end ifset
  242. for lines containing a specified string.
  243. There are two search modes: @dfn{incremental} and @dfn{non-incremental}.
  244. Incremental searches begin before the user has finished typing the
  245. search string.
  246. As each character of the search string is typed, Readline displays
  247. the next entry from the history matching the string typed so far.
  248. An incremental search requires only as many characters as needed to
  249. find the desired history entry.
  250. To search backward in the history for a particular string, type
  251. @kbd{C-r}. Typing @kbd{C-s} searches forward through the history.
  252. The characters present in the value of the @code{isearch-terminators} variable
  253. are used to terminate an incremental search.
  254. If that variable has not been assigned a value, the @key{ESC} and
  255. @kbd{C-J} characters will terminate an incremental search.
  256. @kbd{C-g} will abort an incremental search and restore the original line.
  257. When the search is terminated, the history entry containing the
  258. search string becomes the current line.
  259. To find other matching entries in the history list, type @kbd{C-r} or
  260. @kbd{C-s} as appropriate.
  261. This will search backward or forward in the history for the next
  262. entry matching the search string typed so far.
  263. Any other key sequence bound to a Readline command will terminate
  264. the search and execute that command.
  265. For instance, a @key{RET} will terminate the search and accept
  266. the line, thereby executing the command from the history list.
  267. A movement command will terminate the search, make the last line found
  268. the current line, and begin editing.
  269. Readline remembers the last incremental search string. If two
  270. @kbd{C-r}s are typed without any intervening characters defining a new
  271. search string, any remembered search string is used.
  272. Non-incremental searches read the entire search string before starting
  273. to search for matching history lines. The search string may be
  274. typed by the user or be part of the contents of the current line.
  275. @node Readline Init File
  276. @section Readline Init File
  277. @cindex initialization file, readline
  278. Although the Readline library comes with a set of Emacs-like
  279. keybindings installed by default, it is possible to use a different set
  280. of keybindings.
  281. Any user can customize programs that use Readline by putting
  282. commands in an @dfn{inputrc} file, conventionally in his home directory.
  283. The name of this
  284. @ifset BashFeatures
  285. file is taken from the value of the shell variable @env{INPUTRC}. If
  286. @end ifset
  287. @ifclear BashFeatures
  288. file is taken from the value of the environment variable @env{INPUTRC}. If
  289. @end ifclear
  290. that variable is unset, the default is @file{~/.inputrc}. If that
  291. file does not exist or cannot be read, the ultimate default is
  292. @file{/etc/inputrc}.
  293. When a program which uses the Readline library starts up, the
  294. init file is read, and the key bindings are set.
  295. In addition, the @code{C-x C-r} command re-reads this init file, thus
  296. incorporating any changes that you might have made to it.
  297. @menu
  298. * Readline Init File Syntax:: Syntax for the commands in the inputrc file.
  299. * Conditional Init Constructs:: Conditional key bindings in the inputrc file.
  300. * Sample Init File:: An example inputrc file.
  301. @end menu
  302. @node Readline Init File Syntax
  303. @subsection Readline Init File Syntax
  304. There are only a few basic constructs allowed in the
  305. Readline init file. Blank lines are ignored.
  306. Lines beginning with a @samp{#} are comments.
  307. Lines beginning with a @samp{$} indicate conditional
  308. constructs (@pxref{Conditional Init Constructs}). Other lines
  309. denote variable settings and key bindings.
  310. @table @asis
  311. @item Variable Settings
  312. You can modify the run-time behavior of Readline by
  313. altering the values of variables in Readline
  314. using the @code{set} command within the init file.
  315. The syntax is simple:
  316. @example
  317. set @var{variable} @var{value}
  318. @end example
  319. @noindent
  320. Here, for example, is how to
  321. change from the default Emacs-like key binding to use
  322. @code{vi} line editing commands:
  323. @example
  324. set editing-mode vi
  325. @end example
  326. Variable names and values, where appropriate, are recognized without regard
  327. to case. Unrecognized variable names are ignored.
  328. Boolean variables (those that can be set to on or off) are set to on if
  329. the value is null or empty, @var{on} (case-insensitive), or 1. Any other
  330. value results in the variable being set to off.
  331. @ifset BashFeatures
  332. The @w{@code{bind -V}} command lists the current Readline variable names
  333. and values. @xref{Bash Builtins}.
  334. @end ifset
  335. A great deal of run-time behavior is changeable with the following
  336. variables.
  337. @cindex variables, readline
  338. @table @code
  339. @item bell-style
  340. @vindex bell-style
  341. Controls what happens when Readline wants to ring the terminal bell.
  342. If set to @samp{none}, Readline never rings the bell. If set to
  343. @samp{visible}, Readline uses a visible bell if one is available.
  344. If set to @samp{audible} (the default), Readline attempts to ring
  345. the terminal's bell.
  346. @item bind-tty-special-chars
  347. @vindex bind-tty-special-chars
  348. If set to @samp{on}, Readline attempts to bind the control characters
  349. treated specially by the kernel's terminal driver to their Readline
  350. equivalents.
  351. @item comment-begin
  352. @vindex comment-begin
  353. The string to insert at the beginning of the line when the
  354. @code{insert-comment} command is executed. The default value
  355. is @code{"#"}.
  356. @item completion-display-width
  357. @vindex completion-display-width
  358. The number of screen columns used to display possible matches
  359. when performing completion.
  360. The value is ignored if it is less than 0 or greater than the terminal
  361. screen width.
  362. A value of 0 will cause matches to be displayed one per line.
  363. The default value is -1.
  364. @item completion-ignore-case
  365. @vindex completion-ignore-case
  366. If set to @samp{on}, Readline performs filename matching and completion
  367. in a case-insensitive fashion.
  368. The default value is @samp{off}.
  369. @item completion-map-case
  370. @vindex completion-map-case
  371. If set to @samp{on}, and @var{completion-ignore-case} is enabled, Readline
  372. treats hyphens (@samp{-}) and underscores (@samp{_}) as equivalent when
  373. performing case-insensitive filename matching and completion.
  374. @item completion-prefix-display-length
  375. @vindex completion-prefix-display-length
  376. The length in characters of the common prefix of a list of possible
  377. completions that is displayed without modification. When set to a
  378. value greater than zero, common prefixes longer than this value are
  379. replaced with an ellipsis when displaying possible completions.
  380. @item completion-query-items
  381. @vindex completion-query-items
  382. The number of possible completions that determines when the user is
  383. asked whether the list of possibilities should be displayed.
  384. If the number of possible completions is greater than this value,
  385. Readline will ask the user whether or not he wishes to view
  386. them; otherwise, they are simply listed.
  387. This variable must be set to an integer value greater than or equal to 0.
  388. A negative value means Readline should never ask.
  389. The default limit is @code{100}.
  390. @item convert-meta
  391. @vindex convert-meta
  392. If set to @samp{on}, Readline will convert characters with the
  393. eighth bit set to an @sc{ascii} key sequence by stripping the eighth
  394. bit and prefixing an @key{ESC} character, converting them to a
  395. meta-prefixed key sequence. The default value is @samp{on}.
  396. @item disable-completion
  397. @vindex disable-completion
  398. If set to @samp{On}, Readline will inhibit word completion.
  399. Completion characters will be inserted into the line as if they had
  400. been mapped to @code{self-insert}. The default is @samp{off}.
  401. @item editing-mode
  402. @vindex editing-mode
  403. The @code{editing-mode} variable controls which default set of
  404. key bindings is used. By default, Readline starts up in Emacs editing
  405. mode, where the keystrokes are most similar to Emacs. This variable can be
  406. set to either @samp{emacs} or @samp{vi}.
  407. @item echo-control-characters
  408. When set to @samp{on}, on operating systems that indicate they support it,
  409. readline echoes a character corresponding to a signal generated from the
  410. keyboard. The default is @samp{on}.
  411. @item enable-keypad
  412. @vindex enable-keypad
  413. When set to @samp{on}, Readline will try to enable the application
  414. keypad when it is called. Some systems need this to enable the
  415. arrow keys. The default is @samp{off}.
  416. @item enable-meta-key
  417. When set to @samp{on}, Readline will try to enable any meta modifier
  418. key the terminal claims to support when it is called. On many terminals,
  419. the meta key is used to send eight-bit characters.
  420. The default is @samp{on}.
  421. @item expand-tilde
  422. @vindex expand-tilde
  423. If set to @samp{on}, tilde expansion is performed when Readline
  424. attempts word completion. The default is @samp{off}.
  425. @item history-preserve-point
  426. @vindex history-preserve-point
  427. If set to @samp{on}, the history code attempts to place the point (the
  428. current cursor position) at the
  429. same location on each history line retrieved with @code{previous-history}
  430. or @code{next-history}. The default is @samp{off}.
  431. @item history-size
  432. @vindex history-size
  433. Set the maximum number of history entries saved in the history list. If
  434. set to zero, the number of entries in the history list is not limited.
  435. @item horizontal-scroll-mode
  436. @vindex horizontal-scroll-mode
  437. This variable can be set to either @samp{on} or @samp{off}. Setting it
  438. to @samp{on} means that the text of the lines being edited will scroll
  439. horizontally on a single screen line when they are longer than the width
  440. of the screen, instead of wrapping onto a new screen line. By default,
  441. this variable is set to @samp{off}.
  442. @item input-meta
  443. @vindex input-meta
  444. @vindex meta-flag
  445. If set to @samp{on}, Readline will enable eight-bit input (it
  446. will not clear the eighth bit in the characters it reads),
  447. regardless of what the terminal claims it can support. The
  448. default value is @samp{off}. The name @code{meta-flag} is a
  449. synonym for this variable.
  450. @item isearch-terminators
  451. @vindex isearch-terminators
  452. The string of characters that should terminate an incremental search without
  453. subsequently executing the character as a command (@pxref{Searching}).
  454. If this variable has not been given a value, the characters @key{ESC} and
  455. @kbd{C-J} will terminate an incremental search.
  456. @item keymap
  457. @vindex keymap
  458. Sets Readline's idea of the current keymap for key binding commands.
  459. Acceptable @code{keymap} names are
  460. @code{emacs},
  461. @code{emacs-standard},
  462. @code{emacs-meta},
  463. @code{emacs-ctlx},
  464. @code{vi},
  465. @code{vi-move},
  466. @code{vi-command}, and
  467. @code{vi-insert}.
  468. @code{vi} is equivalent to @code{vi-command}; @code{emacs} is
  469. equivalent to @code{emacs-standard}. The default value is @code{emacs}.
  470. The value of the @code{editing-mode} variable also affects the
  471. default keymap.
  472. @item mark-directories
  473. If set to @samp{on}, completed directory names have a slash
  474. appended. The default is @samp{on}.
  475. @item mark-modified-lines
  476. @vindex mark-modified-lines
  477. This variable, when set to @samp{on}, causes Readline to display an
  478. asterisk (@samp{*}) at the start of history lines which have been modified.
  479. This variable is @samp{off} by default.
  480. @item mark-symlinked-directories
  481. @vindex mark-symlinked-directories
  482. If set to @samp{on}, completed names which are symbolic links
  483. to directories have a slash appended (subject to the value of
  484. @code{mark-directories}).
  485. The default is @samp{off}.
  486. @item match-hidden-files
  487. @vindex match-hidden-files
  488. This variable, when set to @samp{on}, causes Readline to match files whose
  489. names begin with a @samp{.} (hidden files) when performing filename
  490. completion.
  491. If set to @samp{off}, the leading @samp{.} must be
  492. supplied by the user in the filename to be completed.
  493. This variable is @samp{on} by default.
  494. @item menu-complete-display-prefix
  495. @vindex menu-complete-display-prefix
  496. If set to @samp{on}, menu completion displays the common prefix of the
  497. list of possible completions (which may be empty) before cycling through
  498. the list. The default is @samp{off}.
  499. @item output-meta
  500. @vindex output-meta
  501. If set to @samp{on}, Readline will display characters with the
  502. eighth bit set directly rather than as a meta-prefixed escape
  503. sequence. The default is @samp{off}.
  504. @item page-completions
  505. @vindex page-completions
  506. If set to @samp{on}, Readline uses an internal @code{more}-like pager
  507. to display a screenful of possible completions at a time.
  508. This variable is @samp{on} by default.
  509. @item print-completions-horizontally
  510. If set to @samp{on}, Readline will display completions with matches
  511. sorted horizontally in alphabetical order, rather than down the screen.
  512. The default is @samp{off}.
  513. @item revert-all-at-newline
  514. @vindex revert-all-at-newline
  515. If set to @samp{on}, Readline will undo all changes to history lines
  516. before returning when @code{accept-line} is executed. By default,
  517. history lines may be modified and retain individual undo lists across
  518. calls to @code{readline}. The default is @samp{off}.
  519. @item show-all-if-ambiguous
  520. @vindex show-all-if-ambiguous
  521. This alters the default behavior of the completion functions. If
  522. set to @samp{on},
  523. words which have more than one possible completion cause the
  524. matches to be listed immediately instead of ringing the bell.
  525. The default value is @samp{off}.
  526. @item show-all-if-unmodified
  527. @vindex show-all-if-unmodified
  528. This alters the default behavior of the completion functions in
  529. a fashion similar to @var{show-all-if-ambiguous}.
  530. If set to @samp{on},
  531. words which have more than one possible completion without any
  532. possible partial completion (the possible completions don't share
  533. a common prefix) cause the matches to be listed immediately instead
  534. of ringing the bell.
  535. The default value is @samp{off}.
  536. @item skip-completed-text
  537. @vindex skip-completed-text
  538. If set to @samp{on}, this alters the default completion behavior when
  539. inserting a single match into the line. It's only active when
  540. performing completion in the middle of a word. If enabled, readline
  541. does not insert characters from the completion that match characters
  542. after point in the word being completed, so portions of the word
  543. following the cursor are not duplicated.
  544. For instance, if this is enabled, attempting completion when the cursor
  545. is after the @samp{e} in @samp{Makefile} will result in @samp{Makefile}
  546. rather than @samp{Makefilefile}, assuming there is a single possible
  547. completion.
  548. The default value is @samp{off}.
  549. @item visible-stats
  550. @vindex visible-stats
  551. If set to @samp{on}, a character denoting a file's type
  552. is appended to the filename when listing possible
  553. completions. The default is @samp{off}.
  554. @end table
  555. @item Key Bindings
  556. The syntax for controlling key bindings in the init file is
  557. simple. First you need to find the name of the command that you
  558. want to change. The following sections contain tables of the command
  559. name, the default keybinding, if any, and a short description of what
  560. the command does.
  561. Once you know the name of the command, simply place on a line
  562. in the init file the name of the key
  563. you wish to bind the command to, a colon, and then the name of the
  564. command.
  565. There can be no space between the key name and the colon -- that will be
  566. interpreted as part of the key name.
  567. The name of the key can be expressed in different ways, depending on
  568. what you find most comfortable.
  569. In addition to command names, readline allows keys to be bound
  570. to a string that is inserted when the key is pressed (a @var{macro}).
  571. @ifset BashFeatures
  572. The @w{@code{bind -p}} command displays Readline function names and
  573. bindings in a format that can put directly into an initialization file.
  574. @xref{Bash Builtins}.
  575. @end ifset
  576. @table @asis
  577. @item @w{@var{keyname}: @var{function-name} or @var{macro}}
  578. @var{keyname} is the name of a key spelled out in English. For example:
  579. @example
  580. Control-u: universal-argument
  581. Meta-Rubout: backward-kill-word
  582. Control-o: "> output"
  583. @end example
  584. In the above example, @kbd{C-u} is bound to the function
  585. @code{universal-argument},
  586. @kbd{M-DEL} is bound to the function @code{backward-kill-word}, and
  587. @kbd{C-o} is bound to run the macro
  588. expressed on the right hand side (that is, to insert the text
  589. @samp{> output} into the line).
  590. A number of symbolic character names are recognized while
  591. processing this key binding syntax:
  592. @var{DEL},
  593. @var{ESC},
  594. @var{ESCAPE},
  595. @var{LFD},
  596. @var{NEWLINE},
  597. @var{RET},
  598. @var{RETURN},
  599. @var{RUBOUT},
  600. @var{SPACE},
  601. @var{SPC},
  602. and
  603. @var{TAB}.
  604. @item @w{"@var{keyseq}": @var{function-name} or @var{macro}}
  605. @var{keyseq} differs from @var{keyname} above in that strings
  606. denoting an entire key sequence can be specified, by placing
  607. the key sequence in double quotes. Some @sc{gnu} Emacs style key
  608. escapes can be used, as in the following example, but the
  609. special character names are not recognized.
  610. @example
  611. "\C-u": universal-argument
  612. "\C-x\C-r": re-read-init-file
  613. "\e[11~": "Function Key 1"
  614. @end example
  615. In the above example, @kbd{C-u} is again bound to the function
  616. @code{universal-argument} (just as it was in the first example),
  617. @samp{@kbd{C-x} @kbd{C-r}} is bound to the function @code{re-read-init-file},
  618. and @samp{@key{ESC} @key{[} @key{1} @key{1} @key{~}} is bound to insert
  619. the text @samp{Function Key 1}.
  620. @end table
  621. The following @sc{gnu} Emacs style escape sequences are available when
  622. specifying key sequences:
  623. @table @code
  624. @item @kbd{\C-}
  625. control prefix
  626. @item @kbd{\M-}
  627. meta prefix
  628. @item @kbd{\e}
  629. an escape character
  630. @item @kbd{\\}
  631. backslash
  632. @item @kbd{\"}
  633. @key{"}, a double quotation mark
  634. @item @kbd{\'}
  635. @key{'}, a single quote or apostrophe
  636. @end table
  637. In addition to the @sc{gnu} Emacs style escape sequences, a second
  638. set of backslash escapes is available:
  639. @table @code
  640. @item \a
  641. alert (bell)
  642. @item \b
  643. backspace
  644. @item \d
  645. delete
  646. @item \f
  647. form feed
  648. @item \n
  649. newline
  650. @item \r
  651. carriage return
  652. @item \t
  653. horizontal tab
  654. @item \v
  655. vertical tab
  656. @item \@var{nnn}
  657. the eight-bit character whose value is the octal value @var{nnn}
  658. (one to three digits)
  659. @item \x@var{HH}
  660. the eight-bit character whose value is the hexadecimal value @var{HH}
  661. (one or two hex digits)
  662. @end table
  663. When entering the text of a macro, single or double quotes must
  664. be used to indicate a macro definition.
  665. Unquoted text is assumed to be a function name.
  666. In the macro body, the backslash escapes described above are expanded.
  667. Backslash will quote any other character in the macro text,
  668. including @samp{"} and @samp{'}.
  669. For example, the following binding will make @samp{@kbd{C-x} \}
  670. insert a single @samp{\} into the line:
  671. @example
  672. "\C-x\\": "\\"
  673. @end example
  674. @end table
  675. @node Conditional Init Constructs
  676. @subsection Conditional Init Constructs
  677. Readline implements a facility similar in spirit to the conditional
  678. compilation features of the C preprocessor which allows key
  679. bindings and variable settings to be performed as the result
  680. of tests. There are four parser directives used.
  681. @table @code
  682. @item $if
  683. The @code{$if} construct allows bindings to be made based on the
  684. editing mode, the terminal being used, or the application using
  685. Readline. The text of the test extends to the end of the line;
  686. no characters are required to isolate it.
  687. @table @code
  688. @item mode
  689. The @code{mode=} form of the @code{$if} directive is used to test
  690. whether Readline is in @code{emacs} or @code{vi} mode.
  691. This may be used in conjunction
  692. with the @samp{set keymap} command, for instance, to set bindings in
  693. the @code{emacs-standard} and @code{emacs-ctlx} keymaps only if
  694. Readline is starting out in @code{emacs} mode.
  695. @item term
  696. The @code{term=} form may be used to include terminal-specific
  697. key bindings, perhaps to bind the key sequences output by the
  698. terminal's function keys. The word on the right side of the
  699. @samp{=} is tested against both the full name of the terminal and
  700. the portion of the terminal name before the first @samp{-}. This
  701. allows @code{sun} to match both @code{sun} and @code{sun-cmd},
  702. for instance.
  703. @item application
  704. The @var{application} construct is used to include
  705. application-specific settings. Each program using the Readline
  706. library sets the @var{application name}, and you can test for
  707. a particular value.
  708. This could be used to bind key sequences to functions useful for
  709. a specific program. For instance, the following command adds a
  710. key sequence that quotes the current or previous word in Bash:
  711. @example
  712. $if Bash
  713. # Quote the current or previous word
  714. "\C-xq": "\eb\"\ef\""
  715. $endif
  716. @end example
  717. @end table
  718. @item $endif
  719. This command, as seen in the previous example, terminates an
  720. @code{$if} command.
  721. @item $else
  722. Commands in this branch of the @code{$if} directive are executed if
  723. the test fails.
  724. @item $include
  725. This directive takes a single filename as an argument and reads commands
  726. and bindings from that file.
  727. For example, the following directive reads from @file{/etc/inputrc}:
  728. @example
  729. $include /etc/inputrc
  730. @end example
  731. @end table
  732. @node Sample Init File
  733. @subsection Sample Init File
  734. Here is an example of an @var{inputrc} file. This illustrates key
  735. binding, variable assignment, and conditional syntax.
  736. @example
  737. @page
  738. # This file controls the behaviour of line input editing for
  739. # programs that use the GNU Readline library. Existing
  740. # programs include FTP, Bash, and GDB.
  741. #
  742. # You can re-read the inputrc file with C-x C-r.
  743. # Lines beginning with '#' are comments.
  744. #
  745. # First, include any systemwide bindings and variable
  746. # assignments from /etc/Inputrc
  747. $include /etc/Inputrc
  748. #
  749. # Set various bindings for emacs mode.
  750. set editing-mode emacs
  751. $if mode=emacs
  752. Meta-Control-h: backward-kill-word Text after the function name is ignored
  753. #
  754. # Arrow keys in keypad mode
  755. #
  756. #"\M-OD": backward-char
  757. #"\M-OC": forward-char
  758. #"\M-OA": previous-history
  759. #"\M-OB": next-history
  760. #
  761. # Arrow keys in ANSI mode
  762. #
  763. "\M-[D": backward-char
  764. "\M-[C": forward-char
  765. "\M-[A": previous-history
  766. "\M-[B": next-history
  767. #
  768. # Arrow keys in 8 bit keypad mode
  769. #
  770. #"\M-\C-OD": backward-char
  771. #"\M-\C-OC": forward-char
  772. #"\M-\C-OA": previous-history
  773. #"\M-\C-OB": next-history
  774. #
  775. # Arrow keys in 8 bit ANSI mode
  776. #
  777. #"\M-\C-[D": backward-char
  778. #"\M-\C-[C": forward-char
  779. #"\M-\C-[A": previous-history
  780. #"\M-\C-[B": next-history
  781. C-q: quoted-insert
  782. $endif
  783. # An old-style binding. This happens to be the default.
  784. TAB: complete
  785. # Macros that are convenient for shell interaction
  786. $if Bash
  787. # edit the path
  788. "\C-xp": "PATH=$@{PATH@}\e\C-e\C-a\ef\C-f"
  789. # prepare to type a quoted word --
  790. # insert open and close double quotes
  791. # and move to just after the open quote
  792. "\C-x\"": "\"\"\C-b"
  793. # insert a backslash (testing backslash escapes
  794. # in sequences and macros)
  795. "\C-x\\": "\\"
  796. # Quote the current or previous word
  797. "\C-xq": "\eb\"\ef\""
  798. # Add a binding to refresh the line, which is unbound
  799. "\C-xr": redraw-current-line
  800. # Edit variable on current line.
  801. "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
  802. $endif
  803. # use a visible bell if one is available
  804. set bell-style visible
  805. # don't strip characters to 7 bits when reading
  806. set input-meta on
  807. # allow iso-latin1 characters to be inserted rather
  808. # than converted to prefix-meta sequences
  809. set convert-meta off
  810. # display characters with the eighth bit set directly
  811. # rather than as meta-prefixed characters
  812. set output-meta on
  813. # if there are more than 150 possible completions for
  814. # a word, ask the user if he wants to see all of them
  815. set completion-query-items 150
  816. # For FTP
  817. $if Ftp
  818. "\C-xg": "get \M-?"
  819. "\C-xt": "put \M-?"
  820. "\M-.": yank-last-arg
  821. $endif
  822. @end example
  823. @node Bindable Readline Commands
  824. @section Bindable Readline Commands
  825. @menu
  826. * Commands For Moving:: Moving about the line.
  827. * Commands For History:: Getting at previous lines.
  828. * Commands For Text:: Commands for changing text.
  829. * Commands For Killing:: Commands for killing and yanking.
  830. * Numeric Arguments:: Specifying numeric arguments, repeat counts.
  831. * Commands For Completion:: Getting Readline to do the typing for you.
  832. * Keyboard Macros:: Saving and re-executing typed characters
  833. * Miscellaneous Commands:: Other miscellaneous commands.
  834. @end menu
  835. This section describes Readline commands that may be bound to key
  836. sequences.
  837. @ifset BashFeatures
  838. You can list your key bindings by executing
  839. @w{@code{bind -P}} or, for a more terse format, suitable for an
  840. @var{inputrc} file, @w{@code{bind -p}}. (@xref{Bash Builtins}.)
  841. @end ifset
  842. Command names without an accompanying key sequence are unbound by default.
  843. In the following descriptions, @dfn{point} refers to the current cursor
  844. position, and @dfn{mark} refers to a cursor position saved by the
  845. @code{set-mark} command.
  846. The text between the point and mark is referred to as the @dfn{region}.
  847. @node Commands For Moving
  848. @subsection Commands For Moving
  849. @ftable @code
  850. @item beginning-of-line (C-a)
  851. Move to the start of the current line.
  852. @item end-of-line (C-e)
  853. Move to the end of the line.
  854. @item forward-char (C-f)
  855. Move forward a character.
  856. @item backward-char (C-b)
  857. Move back a character.
  858. @item forward-word (M-f)
  859. Move forward to the end of the next word.
  860. Words are composed of letters and digits.
  861. @item backward-word (M-b)
  862. Move back to the start of the current or previous word.
  863. Words are composed of letters and digits.
  864. @ifset BashFeatures
  865. @item shell-forward-word ()
  866. Move forward to the end of the next word.
  867. Words are delimited by non-quoted shell metacharacters.
  868. @item shell-backward-word ()
  869. Move back to the start of the current or previous word.
  870. Words are delimited by non-quoted shell metacharacters.
  871. @end ifset
  872. @item clear-screen (C-l)
  873. Clear the screen and redraw the current line,
  874. leaving the current line at the top of the screen.
  875. @item redraw-current-line ()
  876. Refresh the current line. By default, this is unbound.
  877. @end ftable
  878. @node Commands For History
  879. @subsection Commands For Manipulating The History
  880. @ftable @code
  881. @item accept-line (Newline or Return)
  882. @ifset BashFeatures
  883. Accept the line regardless of where the cursor is.
  884. If this line is
  885. non-empty, add it to the history list according to the setting of
  886. the @env{HISTCONTROL} and @env{HISTIGNORE} variables.
  887. If this line is a modified history line, then restore the history line
  888. to its original state.
  889. @end ifset
  890. @ifclear BashFeatures
  891. Accept the line regardless of where the cursor is.
  892. If this line is
  893. non-empty, it may be added to the history list for future recall with
  894. @code{add_history()}.
  895. If this line is a modified history line, the history line is restored
  896. to its original state.
  897. @end ifclear
  898. @item previous-history (C-p)
  899. Move `back' through the history list, fetching the previous command.
  900. @item next-history (C-n)
  901. Move `forward' through the history list, fetching the next command.
  902. @item beginning-of-history (M-<)
  903. Move to the first line in the history.
  904. @item end-of-history (M->)
  905. Move to the end of the input history, i.e., the line currently
  906. being entered.
  907. @item reverse-search-history (C-r)
  908. Search backward starting at the current line and moving `up' through
  909. the history as necessary. This is an incremental search.
  910. @item forward-search-history (C-s)
  911. Search forward starting at the current line and moving `down' through
  912. the the history as necessary. This is an incremental search.
  913. @item non-incremental-reverse-search-history (M-p)
  914. Search backward starting at the current line and moving `up'
  915. through the history as necessary using a non-incremental search
  916. for a string supplied by the user.
  917. @item non-incremental-forward-search-history (M-n)
  918. Search forward starting at the current line and moving `down'
  919. through the the history as necessary using a non-incremental search
  920. for a string supplied by the user.
  921. @item history-search-forward ()
  922. Search forward through the history for the string of characters
  923. between the start of the current line and the point.
  924. This is a non-incremental search.
  925. By default, this command is unbound.
  926. @item history-search-backward ()
  927. Search backward through the history for the string of characters
  928. between the start of the current line and the point. This
  929. is a non-incremental search. By default, this command is unbound.
  930. @item yank-nth-arg (M-C-y)
  931. Insert the first argument to the previous command (usually
  932. the second word on the previous line) at point.
  933. With an argument @var{n},
  934. insert the @var{n}th word from the previous command (the words
  935. in the previous command begin with word 0). A negative argument
  936. inserts the @var{n}th word from the end of the previous command.
  937. Once the argument @var{n} is computed, the argument is extracted
  938. as if the @samp{!@var{n}} history expansion had been specified.
  939. @item yank-last-arg (M-. or M-_)
  940. Insert last argument to the previous command (the last word of the
  941. previous history entry).
  942. With a numeric argument, behave exactly like @code{yank-nth-arg}.
  943. Successive calls to @code{yank-last-arg} move back through the history
  944. list, inserting the last word (or the word specified by the argument to
  945. the first call) of each line in turn.
  946. Any numeric argument supplied to these successive calls determines
  947. the direction to move through the history. A negative argument switches
  948. the direction through the history (back or forward).
  949. The history expansion facilities are used to extract the last argument,
  950. as if the @samp{!$} history expansion had been specified.
  951. @end ftable
  952. @node Commands For Text
  953. @subsection Commands For Changing Text
  954. @ftable @code
  955. @item delete-char (C-d)
  956. Delete the character at point. If point is at the
  957. beginning of the line, there are no characters in the line, and
  958. the last character typed was not bound to @code{delete-char}, then
  959. return @sc{eof}.
  960. @item backward-delete-char (Rubout)
  961. Delete the character behind the cursor. A numeric argument means
  962. to kill the characters instead of deleting them.
  963. @item forward-backward-delete-char ()
  964. Delete the character under the cursor, unless the cursor is at the
  965. end of the line, in which case the character behind the cursor is
  966. deleted. By default, this is not bound to a key.
  967. @item quoted-insert (C-q or C-v)
  968. Add the next character typed to the line verbatim. This is
  969. how to insert key sequences like @kbd{C-q}, for example.
  970. @ifclear BashFeatures
  971. @item tab-insert (M-@key{TAB})
  972. Insert a tab character.
  973. @end ifclear
  974. @item self-insert (a, b, A, 1, !, @dots{})
  975. Insert yourself.
  976. @item transpose-chars (C-t)
  977. Drag the character before the cursor forward over
  978. the character at the cursor, moving the
  979. cursor forward as well. If the insertion point
  980. is at the end of the line, then this
  981. transposes the last two characters of the line.
  982. Negative arguments have no effect.
  983. @item transpose-words (M-t)
  984. Drag the word before point past the word after point,
  985. moving point past that word as well.
  986. If the insertion point is at the end of the line, this transposes
  987. the last two words on the line.
  988. @item upcase-word (M-u)
  989. Uppercase the current (or following) word. With a negative argument,
  990. uppercase the previous word, but do not move the cursor.
  991. @item downcase-word (M-l)
  992. Lowercase the current (or following) word. With a negative argument,
  993. lowercase the previous word, but do not move the cursor.
  994. @item capitalize-word (M-c)
  995. Capitalize the current (or following) word. With a negative argument,
  996. capitalize the previous word, but do not move the cursor.
  997. @item overwrite-mode ()
  998. Toggle overwrite mode. With an explicit positive numeric argument,
  999. switches to overwrite mode. With an explicit non-positive numeric
  1000. argument, switches to insert mode. This command affects only
  1001. @code{emacs} mode; @code{vi} mode does overwrite differently.
  1002. Each call to @code{readline()} starts in insert mode.
  1003. In overwrite mode, characters bound to @code{self-insert} replace
  1004. the text at point rather than pushing the text to the right.
  1005. Characters bound to @code{backward-delete-char} replace the character
  1006. before point with a space.
  1007. By default, this command is unbound.
  1008. @end ftable
  1009. @node Commands For Killing
  1010. @subsection Killing And Yanking
  1011. @ftable @code
  1012. @item kill-line (C-k)
  1013. Kill the text from point to the end of the line.
  1014. @item backward-kill-line (C-x Rubout)
  1015. Kill backward to the beginning of the line.
  1016. @item unix-line-discard (C-u)
  1017. Kill backward from the cursor to the beginning of the current line.
  1018. @item kill-whole-line ()
  1019. Kill all characters on the current line, no matter where point is.
  1020. By default, this is unbound.
  1021. @item kill-word (M-d)
  1022. Kill from point to the end of the current word, or if between
  1023. words, to the end of the next word.
  1024. Word boundaries are the same as @code{forward-word}.
  1025. @item backward-kill-word (M-@key{DEL})
  1026. Kill the word behind point.
  1027. Word boundaries are the same as @code{backward-word}.
  1028. @ifset BashFeatures
  1029. @item shell-kill-word ()
  1030. Kill from point to the end of the current word, or if between
  1031. words, to the end of the next word.
  1032. Word boundaries are the same as @code{shell-forward-word}.
  1033. @item shell-backward-kill-word ()
  1034. Kill the word behind point.
  1035. Word boundaries are the same as @code{shell-backward-word}.
  1036. @end ifset
  1037. @item unix-word-rubout (C-w)
  1038. Kill the word behind point, using white space as a word boundary.
  1039. The killed text is saved on the kill-ring.
  1040. @item unix-filename-rubout ()
  1041. Kill the word behind point, using white space and the slash character
  1042. as the word boundaries.
  1043. The killed text is saved on the kill-ring.
  1044. @item delete-horizontal-space ()
  1045. Delete all spaces and tabs around point. By default, this is unbound.
  1046. @item kill-region ()
  1047. Kill the text in the current region.
  1048. By default, this command is unbound.
  1049. @item copy-region-as-kill ()
  1050. Copy the text in the region to the kill buffer, so it can be yanked
  1051. right away. By default, this command is unbound.
  1052. @item copy-backward-word ()
  1053. Copy the word before point to the kill buffer.
  1054. The word boundaries are the same as @code{backward-word}.
  1055. By default, this command is unbound.
  1056. @item copy-forward-word ()
  1057. Copy the word following point to the kill buffer.
  1058. The word boundaries are the same as @code{forward-word}.
  1059. By default, this command is unbound.
  1060. @item yank (C-y)
  1061. Yank the top of the kill ring into the buffer at point.
  1062. @item yank-pop (M-y)
  1063. Rotate the kill-ring, and yank the new top. You can only do this if
  1064. the prior command is @code{yank} or @code{yank-pop}.
  1065. @end ftable
  1066. @node Numeric Arguments
  1067. @subsection Specifying Numeric Arguments
  1068. @ftable @code
  1069. @item digit-argument (@kbd{M-0}, @kbd{M-1}, @dots{} @kbd{M--})
  1070. Add this digit to the argument already accumulating, or start a new
  1071. argument. @kbd{M--} starts a negative argument.
  1072. @item universal-argument ()
  1073. This is another way to specify an argument.
  1074. If this command is followed by one or more digits, optionally with a
  1075. leading minus sign, those digits define the argument.
  1076. If the command is followed by digits, executing @code{universal-argument}
  1077. again ends the numeric argument, but is otherwise ignored.
  1078. As a special case, if this command is immediately followed by a
  1079. character that is neither a digit or minus sign, the argument count
  1080. for the next command is multiplied by four.
  1081. The argument count is initially one, so executing this function the
  1082. first time makes the argument count four, a second time makes the
  1083. argument count sixteen, and so on.
  1084. By default, this is not bound to a key.
  1085. @end ftable
  1086. @node Commands For Completion
  1087. @subsection Letting Readline Type For You
  1088. @ftable @code
  1089. @item complete (@key{TAB})
  1090. Attempt to perform completion on the text before point.
  1091. The actual completion performed is application-specific.
  1092. @ifset BashFeatures
  1093. Bash attempts completion treating the text as a variable (if the
  1094. text begins with @samp{$}), username (if the text begins with
  1095. @samp{~}), hostname (if the text begins with @samp{@@}), or
  1096. command (including aliases and functions) in turn. If none
  1097. of these produces a match, filename completion is attempted.
  1098. @end ifset
  1099. @ifclear BashFeatures
  1100. The default is filename completion.
  1101. @end ifclear
  1102. @item possible-completions (M-?)
  1103. List the possible completions of the text before point.
  1104. When displaying completions, Readline sets the number of columns used
  1105. for display to the value of @code{completion-display-width}, the value of
  1106. the environment variable @env{COLUMNS}, or the screen width, in that order.
  1107. @item insert-completions (M-*)
  1108. Insert all completions of the text before point that would have
  1109. been generated by @code{possible-completions}.
  1110. @item menu-complete ()
  1111. Similar to @code{complete}, but replaces the word to be completed
  1112. with a single match from the list of possible completions.
  1113. Repeated execution of @code{menu-complete} steps through the list
  1114. of possible completions, inserting each match in turn.
  1115. At the end of the list of completions, the bell is rung
  1116. (subject to the setting of @code{bell-style})
  1117. and the original text is restored.
  1118. An argument of @var{n} moves @var{n} positions forward in the list
  1119. of matches; a negative argument may be used to move backward
  1120. through the list.
  1121. This command is intended to be bound to @key{TAB}, but is unbound
  1122. by default.
  1123. @item menu-complete-backward ()
  1124. Identical to @code{menu-complete}, but moves backward through the list
  1125. of possible completions, as if @code{menu-complete} had been given a
  1126. negative argument.
  1127. @item delete-char-or-list ()
  1128. Deletes the character under the cursor if not at the beginning or
  1129. end of the line (like @code{delete-char}).
  1130. If at the end of the line, behaves identically to
  1131. @code{possible-completions}.
  1132. This command is unbound by default.
  1133. @ifset BashFeatures
  1134. @item complete-filename (M-/)
  1135. Attempt filename completion on the text before point.
  1136. @item possible-filename-completions (C-x /)
  1137. List the possible completions of the text before point,
  1138. treating it as a filename.
  1139. @item complete-username (M-~)
  1140. Attempt completion on the text before point, treating
  1141. it as a username.
  1142. @item possible-username-completions (C-x ~)
  1143. List the possible completions of the text before point,
  1144. treating it as a username.
  1145. @item complete-variable (M-$)
  1146. Attempt completion on the text before point, treating
  1147. it as a shell variable.
  1148. @item possible-variable-completions (C-x $)
  1149. List the possible completions of the text before point,
  1150. treating it as a shell variable.
  1151. @item complete-hostname (M-@@)
  1152. Attempt completion on the text before point, treating
  1153. it as a hostname.
  1154. @item possible-hostname-completions (C-x @@)
  1155. List the possible completions of the text before point,
  1156. treating it as a hostname.
  1157. @item complete-command (M-!)
  1158. Attempt completion on the text before point, treating
  1159. it as a command name. Command completion attempts to
  1160. match the text against aliases, reserved words, shell
  1161. functions, shell builtins, and finally executable filenames,
  1162. in that order.
  1163. @item possible-command-completions (C-x !)
  1164. List the possible completions of the text before point,
  1165. treating it as a command name.
  1166. @item dynamic-complete-history (M-@key{TAB})
  1167. Attempt completion on the text before point, comparing
  1168. the text against lines from the history list for possible
  1169. completion matches.
  1170. @item dabbrev-expand ()
  1171. Attempt menu completion on the text before point, comparing
  1172. the text against lines from the history list for possible
  1173. completion matches.
  1174. @item complete-into-braces (M-@{)
  1175. Perform filename completion and insert the list of possible completions
  1176. enclosed within braces so the list is available to the shell
  1177. (@pxref{Brace Expansion}).
  1178. @end ifset
  1179. @end ftable
  1180. @node Keyboard Macros
  1181. @subsection Keyboard Macros
  1182. @ftable @code
  1183. @item start-kbd-macro (C-x ()
  1184. Begin saving the characters typed into the current keyboard macro.
  1185. @item end-kbd-macro (C-x ))
  1186. Stop saving the characters typed into the current keyboard macro
  1187. and save the definition.
  1188. @item call-last-kbd-macro (C-x e)
  1189. Re-execute the last keyboard macro defined, by making the characters
  1190. in the macro appear as if typed at the keyboard.
  1191. @end ftable
  1192. @node Miscellaneous Commands
  1193. @subsection Some Miscellaneous Commands
  1194. @ftable @code
  1195. @item re-read-init-file (C-x C-r)
  1196. Read in the contents of the @var{inputrc} file, and incorporate
  1197. any bindings or variable assignments found there.
  1198. @item abort (C-g)
  1199. Abort the current editing command and
  1200. ring the terminal's bell (subject to the setting of
  1201. @code{bell-style}).
  1202. @item do-uppercase-version (M-a, M-b, M-@var{x}, @dots{})
  1203. If the metafied character @var{x} is lowercase, run the command
  1204. that is bound to the corresponding uppercase character.
  1205. @item prefix-meta (@key{ESC})
  1206. Metafy the next character typed. This is for keyboards
  1207. without a meta key. Typing @samp{@key{ESC} f} is equivalent to typing
  1208. @kbd{M-f}.
  1209. @item undo (C-_ or C-x C-u)
  1210. Incremental undo, separately remembered for each line.
  1211. @item revert-line (M-r)
  1212. Undo all changes made to this line. This is like executing the @code{undo}
  1213. command enough times to get back to the beginning.
  1214. @ifset BashFeatures
  1215. @item tilde-expand (M-&)
  1216. @end ifset
  1217. @ifclear BashFeatures
  1218. @item tilde-expand (M-~)
  1219. @end ifclear
  1220. Perform tilde expansion on the current word.
  1221. @item set-mark (C-@@)
  1222. Set the mark to the point. If a
  1223. numeric argument is supplied, the mark is set to that position.
  1224. @item exchange-point-and-mark (C-x C-x)
  1225. Swap the point with the mark. The current cursor position is set to
  1226. the saved position, and the old cursor position is saved as the mark.
  1227. @item character-search (C-])
  1228. A character is read and point is moved to the next occurrence of that
  1229. character. A negative count searches for previous occurrences.
  1230. @item character-search-backward (M-C-])
  1231. A character is read and point is moved to the previous occurrence
  1232. of that character. A negative count searches for subsequent
  1233. occurrences.
  1234. @item skip-csi-sequence ()
  1235. Read enough characters to consume a multi-key sequence such as those
  1236. defined for keys like Home and End. Such sequences begin with a
  1237. Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
  1238. bound to "\e[", keys producing such sequences will have no effect
  1239. unless explicitly bound to a readline command, instead of inserting
  1240. stray characters into the editing buffer. This is unbound by default,
  1241. but usually bound to ESC-[.
  1242. @item insert-comment (M-#)
  1243. Without a numeric argument, the value of the @code{comment-begin}
  1244. variable is inserted at the beginning of the current line.
  1245. If a numeric argument is supplied, this command acts as a toggle: if
  1246. the characters at the beginning of the line do not match the value
  1247. of @code{comment-begin}, the value is inserted, otherwise
  1248. the characters in @code{comment-begin} are deleted from the beginning of
  1249. the line.
  1250. In either case, the line is accepted as if a newline had been typed.
  1251. @ifset BashFeatures
  1252. The default value of @code{comment-begin} causes this command
  1253. to make the current line a shell comment.
  1254. If a numeric argument causes the comment character to be removed, the line
  1255. will be executed by the shell.
  1256. @end ifset
  1257. @item dump-functions ()
  1258. Print all of the functions and their key bindings to the
  1259. Readline output stream. If a numeric argument is supplied,
  1260. the output is formatted in such a way that it can be made part
  1261. of an @var{inputrc} file. This command is unbound by default.
  1262. @item dump-variables ()
  1263. Print all of the settable variables and their values to the
  1264. Readline output stream. If a numeric argument is supplied,
  1265. the output is formatted in such a way that it can be made part
  1266. of an @var{inputrc} file. This command is unbound by default.
  1267. @item dump-macros ()
  1268. Print all of the Readline key sequences bound to macros and the
  1269. strings they output. If a numeric argument is supplied,
  1270. the output is formatted in such a way that it can be made part
  1271. of an @var{inputrc} file. This command is unbound by default.
  1272. @ifset BashFeatures
  1273. @item glob-complete-word (M-g)
  1274. The word before point is treated as a pattern for pathname expansion,
  1275. with an asterisk implicitly appended. This pattern is used to
  1276. generate a list of matching file names for possible completions.
  1277. @item glob-expand-word (C-x *)
  1278. The word before point is treated as a pattern for pathname expansion,
  1279. and the list of matching file names is inserted, replacing the word.
  1280. If a numeric argument is supplied, a @samp{*} is appended before
  1281. pathname expansion.
  1282. @item glob-list-expansions (C-x g)
  1283. The list of expansions that would have been generated by
  1284. @code{glob-expand-word} is displayed, and the line is redrawn.
  1285. If a numeric argument is supplied, a @samp{*} is appended before
  1286. pathname expansion.
  1287. @item display-shell-version (C-x C-v)
  1288. Display version information about the current instance of Bash.
  1289. @item shell-expand-line (M-C-e)
  1290. Expand the line as the shell does.
  1291. This performs alias and history expansion as well as all of the shell
  1292. word expansions (@pxref{Shell Expansions}).
  1293. @item history-expand-line (M-^)
  1294. Perform history expansion on the current line.
  1295. @item magic-space ()
  1296. Perform history expansion on the current line and insert a space
  1297. (@pxref{History Interaction}).
  1298. @item alias-expand-line ()
  1299. Perform alias expansion on the current line (@pxref{Aliases}).
  1300. @item history-and-alias-expand-line ()
  1301. Perform history and alias expansion on the current line.
  1302. @item insert-last-argument (M-. or M-_)
  1303. A synonym for @code{yank-last-arg}.
  1304. @item operate-and-get-next (C-o)
  1305. Accept the current line for execution and fetch the next line
  1306. relative to the current line from the history for editing. Any
  1307. argument is ignored.
  1308. @item edit-and-execute-command (C-xC-e)
  1309. Invoke an editor on the current command line, and execute the result as shell
  1310. commands.
  1311. Bash attempts to invoke
  1312. @code{$VISUAL}, @code{$EDITOR}, and @code{emacs}
  1313. as the editor, in that order.
  1314. @end ifset
  1315. @ifclear BashFeatures
  1316. @item emacs-editing-mode (C-e)
  1317. When in @code{vi} command mode, this causes a switch to @code{emacs}
  1318. editing mode.
  1319. @item vi-editing-mode (M-C-j)
  1320. When in @code{emacs} editing mode, this causes a switch to @code{vi}
  1321. editing mode.
  1322. @end ifclear
  1323. @end ftable
  1324. @node Readline vi Mode
  1325. @section Readline vi Mode
  1326. While the Readline library does not have a full set of @code{vi}
  1327. editing functions, it does contain enough to allow simple editing
  1328. of the line. The Readline @code{vi} mode behaves as specified in
  1329. the @sc{posix} standard.
  1330. @ifset BashFeatures
  1331. In order to switch interactively between @code{emacs} and @code{vi}
  1332. editing modes, use the @samp{set -o emacs} and @samp{set -o vi}
  1333. commands (@pxref{The Set Builtin}).
  1334. @end ifset
  1335. @ifclear BashFeatures
  1336. In order to switch interactively between @code{emacs} and @code{vi}
  1337. editing modes, use the command @kbd{M-C-j} (bound to emacs-editing-mode
  1338. when in @code{vi} mode and to vi-editing-mode in @code{emacs} mode).
  1339. @end ifclear
  1340. The Readline default is @code{emacs} mode.
  1341. When you enter a line in @code{vi} mode, you are already placed in
  1342. `insertion' mode, as if you had typed an @samp{i}. Pressing @key{ESC}
  1343. switches you into `command' mode, where you can edit the text of the
  1344. line with the standard @code{vi} movement keys, move to previous
  1345. history lines with @samp{k} and subsequent lines with @samp{j}, and
  1346. so forth.
  1347. @ifset BashFeatures
  1348. @node Programmable Completion
  1349. @section Programmable Completion
  1350. @cindex programmable completion
  1351. When word completion is attempted for an argument to a command for
  1352. which a completion specification (a @var{compspec}) has been defined
  1353. using the @code{complete} builtin (@pxref{Programmable Completion Builtins}),
  1354. the programmable completion facilities are invoked.
  1355. First, the command name is identified.
  1356. If a compspec has been defined for that command, the
  1357. compspec is used to generate the list of possible completions for the word.
  1358. If the command word is the empty string (completion attempted at the
  1359. beginning of an empty line), any compspec defined with
  1360. the @option{-E} option to @code{complete} is used.
  1361. If the command word is a full pathname, a compspec for the full
  1362. pathname is searched for first.
  1363. If no compspec is found for the full pathname, an attempt is made to
  1364. find a compspec for the portion following the final slash.
  1365. If those searches do not result in a compspec, any compspec defined with
  1366. the @option{-D} option to @code{complete} is used as the default.
  1367. Once a compspec has been found, it is used to generate the list of
  1368. matching words.
  1369. If a compspec is not found, the default Bash completion
  1370. described above (@pxref{Commands For Completion}) is performed.
  1371. First, the actions specified by the compspec are used.
  1372. Only matches which are prefixed by the word being completed are
  1373. returned.
  1374. When the @option{-f} or @option{-d} option is used for filename or
  1375. directory name completion, the shell variable @env{FIGNORE} is
  1376. used to filter the matches.
  1377. @xref{Bash Variables}, for a description of @env{FIGNORE}.
  1378. Any completions specified by a filename expansion pattern to the
  1379. @option{-G} option are generated next.
  1380. The words generated by the pattern need not match the word being completed.
  1381. The @env{GLOBIGNORE} shell variable is not used to filter the matches,
  1382. but the @env{FIGNORE} shell variable is used.
  1383. Next, the string specified as the argument to the @option{-W} option
  1384. is considered.
  1385. The string is first split using the characters in the @env{IFS}
  1386. special variable as delimiters.
  1387. Shell quoting is honored.
  1388. Each word is then expanded using
  1389. brace expansion, tilde expansion, parameter and variable expansion,
  1390. command substitution, and arithmetic expansion,
  1391. as described above (@pxref{Shell Expansions}).
  1392. The results are split using the rules described above
  1393. (@pxref{Word Splitting}).
  1394. The results of the expansion are prefix-matched against the word being
  1395. completed, and the matching words become the possible completions.
  1396. After these matches have been generated, any shell function or command
  1397. specified with the @option{-F} and @option{-C} options is invoked.
  1398. When the command or function is invoked, the @env{COMP_LINE},
  1399. @env{COMP_POINT}, @env{COMP_KEY}, and @env{COMP_TYPE} variables are
  1400. assigned values as described above (@pxref{Bash Variables}).
  1401. If a shell function is being invoked, the @env{COMP_WORDS} and
  1402. @env{COMP_CWORD} variables are also set.
  1403. When the function or command is invoked, the first argument is the
  1404. name of the command whose arguments are being completed, the
  1405. second argument is the word being completed, and the third argument
  1406. is the word preceding the word being completed on the current command line.
  1407. No filtering of the generated completions against the word being completed
  1408. is performed; the function or command has complete freedom in generating
  1409. the matches.
  1410. Any function specified with @option{-F} is invoked first.
  1411. The function may use any of the shell facilities, including the
  1412. @code{compgen} and @code{compopt} builtins described below
  1413. (@pxref{Programmable Completion Builtins}), to generate the matches.
  1414. It must put the possible completions in the @env{COMPREPLY} array
  1415. variable.
  1416. Next, any command specified with the @option{-C} option is invoked
  1417. in an environment equivalent to command substitution.
  1418. It should print a list of completions, one per line, to
  1419. the standard output.
  1420. Backslash may be used to escape a newline, if necessary.
  1421. After all of the possible completions are generated, any filter
  1422. specified with the @option{-X} option is applied to the list.
  1423. The filter is a pattern as used for pathname expansion; a @samp{&}
  1424. in the pattern is replaced with the text of the word being completed.
  1425. A literal @samp{&} may be escaped with a backslash; the backslash
  1426. is removed before attempting a match.
  1427. Any completion that matches the pattern will be removed from the list.
  1428. A leading @samp{!} negates the pattern; in this case any completion
  1429. not matching the pattern will be removed.
  1430. Finally, any prefix and suffix specified with the @option{-P} and @option{-S}
  1431. options are added to each member of the completion list, and the result is
  1432. returned to the Readline completion code as the list of possible
  1433. completions.
  1434. If the previously-applied actions do not generate any matches, and the
  1435. @option{-o dirnames} option was supplied to @code{complete} when the
  1436. compspec was defined, directory name completion is attempted.
  1437. If the @option{-o plusdirs} option was supplied to @code{complete} when
  1438. the compspec was defined, directory name completion is attempted and any
  1439. matches are added to the results of the other actions.
  1440. By default, if a compspec is found, whatever it generates is returned to
  1441. the completion code as the full set of possible completions.
  1442. The default Bash completions are not attempted, and the Readline default
  1443. of filename completion is disabled.
  1444. If the @option{-o bashdefault} option was supplied to @code{complete} when
  1445. the compspec was defined, the default Bash completions are attempted
  1446. if the compspec generates no matches.
  1447. If the @option{-o default} option was supplied to @code{complete} when the
  1448. compspec was defined, Readline's default completion will be performed
  1449. if the compspec (and, if attempted, the default Bash completions)
  1450. generate no matches.
  1451. When a compspec indicates that directory name completion is desired,
  1452. the programmable completion functions force Readline to append a slash
  1453. to completed names which are symbolic links to directories, subject to
  1454. the value of the @var{mark-directories} Readline variable, regardless
  1455. of the setting of the @var{mark-symlinked-directories} Readline variable.
  1456. There is some support for dynamically modifying completions. This is
  1457. most useful when used in combination with a default completion specified
  1458. with @option{-D}. It's possible for shell functions executed as completion
  1459. handlers to indicate that completion should be retried by returning an
  1460. exit status of 124. If a shell function returns 124, and changes
  1461. the compspec associated with the command on which completion is being
  1462. attempted (supplied as the first argument when the function is executed),
  1463. programmable completion restarts from the beginning, with an
  1464. attempt to find a new compspec for that command. This allows a set of
  1465. completions to be built dynamically as completion is attempted, rather than
  1466. being loaded all at once.
  1467. For instance, assuming that there is a library of compspecs, each kept in a
  1468. file corresponding to the name of the command, the following default
  1469. completion function would load completions dynamically:
  1470. @example
  1471. _completion_loader()
  1472. @{
  1473. . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124
  1474. @}
  1475. complete -D -F _completion_loader
  1476. @end example
  1477. @node Programmable Completion Builtins
  1478. @section Programmable Completion Builtins
  1479. @cindex completion builtins
  1480. Two builtin commands are available to manipulate the programmable completion
  1481. facilities.
  1482. @table @code
  1483. @item compgen
  1484. @btindex compgen
  1485. @example
  1486. @code{compgen [@var{option}] [@var{word}]}
  1487. @end example
  1488. Generate possible completion matches for @var{word} according to
  1489. the @var{option}s, which may be any option accepted by the
  1490. @code{complete}
  1491. builtin with the exception of @option{-p} and @option{-r}, and write
  1492. the matches to the standard output.
  1493. When using the @option{-F} or @option{-C} options, the various shell variables
  1494. set by the programmable completion facilities, while available, will not
  1495. have useful values.
  1496. The matches will be generated in the same way as if the programmable
  1497. completion code had generated them directly from a completion specification
  1498. with the same flags.
  1499. If @var{word} is specified, only those completions matching @var{word}
  1500. will be displayed.
  1501. The return value is true unless an invalid option is supplied, or no
  1502. matches were generated.
  1503. @item complete
  1504. @btindex complete
  1505. @example
  1506. @code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-DE] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
  1507. [-F @var{function}] [-C @var{command}] [-X @var{filterpat}]
  1508. [-P @var{prefix}] [-S @var{suffix}] @var{name} [@var{name} @dots{}]}
  1509. @code{complete -pr [-DE] [@var{name} @dots{}]}
  1510. @end example
  1511. Specify how arguments to each @var{name} should be completed.
  1512. If the @option{-p} option is supplied, or if no options are supplied, existing
  1513. completion specifications are printed in a way that allows them to be
  1514. reused as input.
  1515. The @option{-r} option removes a completion specification for
  1516. each @var{name}, or, if no @var{name}s are supplied, all
  1517. completion specifications.
  1518. The @option{-D} option indicates that the remaining options and actions should
  1519. apply to the ``default'' command completion; that is, completion attempted
  1520. on a command for which no completion has previously been defined.
  1521. The @option{-E} option indicates that the remaining options and actions should
  1522. apply to ``empty'' command completion; that is, completion attempted on a
  1523. blank line.
  1524. The process of applying these completion specifications when word completion
  1525. is attempted is described above (@pxref{Programmable Completion}). The
  1526. @option{-D} option takes precedence over @option{-E}.
  1527. Other options, if specified, have the following meanings.
  1528. The arguments to the @option{-G}, @option{-W}, and @option{-X} options
  1529. (and, if necessary, the @option{-P} and @option{-S} options)
  1530. should be quoted to protect them from expansion before the
  1531. @code{complete} builtin is invoked.
  1532. @table @code
  1533. @item -o @var{comp-option}
  1534. The @var{comp-option} controls several aspects of the compspec's behavior
  1535. beyond the simple generation of completions.
  1536. @var{comp-option} may be one of:
  1537. @table @code
  1538. @item bashdefault
  1539. Perform the rest of the default Bash completions if the compspec
  1540. generates no matches.
  1541. @item default
  1542. Use Readline's default filename completion if the compspec generates
  1543. no matches.
  1544. @item dirnames
  1545. Perform directory name completion if the compspec generates no matches.
  1546. @item filenames
  1547. Tell Readline that the compspec generates filenames, so it can perform any
  1548. filename-specific processing (like adding a slash to directory names
  1549. quoting special characters, or suppressing trailing spaces).
  1550. This option is intended to be used with shell functions specified
  1551. with @option{-F}.
  1552. @item nospace
  1553. Tell Readline not to append a space (the default) to words completed at
  1554. the end of the line.
  1555. @item plusdirs
  1556. After any matches defined by the compspec are generated,
  1557. directory name completion is attempted and any
  1558. matches are added to the results of the other actions.
  1559. @end table
  1560. @item -A @var{action}
  1561. The @var{action} may be one of the following to generate a list of possible
  1562. completions:
  1563. @table @code
  1564. @item alias
  1565. Alias names. May also be specified as @option{-a}.
  1566. @item arrayvar
  1567. Array variable names.
  1568. @item binding
  1569. Readline key binding names (@pxref{Bindable Readline Commands}).
  1570. @item builtin
  1571. Names of shell builtin commands. May also be specified as @option{-b}.
  1572. @item command
  1573. Command names. May also be specified as @option{-c}.
  1574. @item directory
  1575. Directory names. May also be specified as @option{-d}.
  1576. @item disabled
  1577. Names of disabled shell builtins.
  1578. @item enabled
  1579. Names of enabled shell builtins.
  1580. @item export
  1581. Names of exported shell variables. May also be specified as @option{-e}.
  1582. @item file
  1583. File names. May also be specified as @option{-f}.
  1584. @item function
  1585. Names of shell functions.
  1586. @item group
  1587. Group names. May also be specified as @option{-g}.
  1588. @item helptopic
  1589. Help topics as accepted by the @code{help} builtin (@pxref{Bash Builtins}).
  1590. @item hostname
  1591. Hostnames, as taken from the file specified by the
  1592. @env{HOSTFILE} shell variable (@pxref{Bash Variables}).
  1593. @item job
  1594. Job names, if job control is active. May also be specified as @option{-j}.
  1595. @item keyword
  1596. Shell reserved words. May also be specified as @option{-k}.
  1597. @item running
  1598. Names of running jobs, if job control is active.
  1599. @item service
  1600. Service names. May also be specified as @option{-s}.
  1601. @item setopt
  1602. Valid arguments for the @option{-o} option to the @code{set} builtin
  1603. (@pxref{The Set Builtin}).
  1604. @item shopt
  1605. Shell option names as accepted by the @code{shopt} builtin
  1606. (@pxref{Bash Builtins}).
  1607. @item signal
  1608. Signal names.
  1609. @item stopped
  1610. Names of stopped jobs, if job control is active.
  1611. @item user
  1612. User names. May also be specified as @option{-u}.
  1613. @item variable
  1614. Names of all shell variables. May also be specified as @option{-v}.
  1615. @end table
  1616. @item -C @var{command}
  1617. @var{command} is executed in a subshell environment, and its output is
  1618. used as the possible completions.
  1619. @item -F @var{function}
  1620. The shell function @var{function} is executed in the current shell
  1621. environment.
  1622. When it finishes, the possible completions are retrieved from the value
  1623. of the @env{COMPREPLY} array variable.
  1624. @item -G @var{globpat}
  1625. The filename expansion pattern @var{globpat} is expanded to generate
  1626. the possible completions.
  1627. @item -P @var{prefix}
  1628. @var{prefix} is added at the beginning of each possible completion
  1629. after all other options have been applied.
  1630. @item -S @var{suffix}
  1631. @var{suffix} is appended to each possible completion
  1632. after all other options have been applied.
  1633. @item -W @var{wordlist}
  1634. The @var{wordlist} is split using the characters in the
  1635. @env{IFS} special variable as delimiters, and each resultant word
  1636. is expanded.
  1637. The possible completions are the members of the resultant list which
  1638. match the word being completed.
  1639. @item -X @var{filterpat}
  1640. @var{filterpat} is a pattern as used for filename expansion.
  1641. It is applied to the list of possible completions generated by the
  1642. preceding options and arguments, and each completion matching
  1643. @var{filterpat} is removed from the list.
  1644. A leading @samp{!} in @var{filterpat} negates the pattern; in this
  1645. case, any completion not matching @var{filterpat} is removed.
  1646. @end table
  1647. The return value is true unless an invalid option is supplied, an option
  1648. other than @option{-p} or @option{-r} is supplied without a @var{name}
  1649. argument, an attempt is made to remove a completion specification for
  1650. a @var{name} for which no specification exists, or
  1651. an error occurs adding a completion specification.
  1652. @item compopt
  1653. @btindex compopt
  1654. @example
  1655. @code{compopt} [-o @var{option}] [-DE] [+o @var{option}] [@var{name}]
  1656. @end example
  1657. Modify completion options for each @var{name} according to the
  1658. @var{option}s, or for the currently-executing completion if no @var{name}s
  1659. are supplied.
  1660. If no @var{option}s are given, display the completion options for each
  1661. @var{name} or the current completion.
  1662. The possible values of @var{option} are those valid for the @code{complete}
  1663. builtin described above.
  1664. The @option{-D} option indicates that the remaining options should
  1665. apply to the ``default'' command completion; that is, completion attempted
  1666. on a command for which no completion has previously been defined.
  1667. The @option{-E} option indicates that the remaining options should
  1668. apply to ``empty'' command completion; that is, completion attempted on a
  1669. blank line.
  1670. The @option{-D} option takes precedence over @option{-E}.
  1671. The return value is true unless an invalid option is supplied, an attempt
  1672. is made to modify the options for a @var{name} for which no completion
  1673. specification exists, or an output error occurs.
  1674. @end table
  1675. @end ifset