1 |
106 |
markom |
@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 |
|
|
@setchapternewpage odd
|
5 |
|
|
|
6 |
|
|
@ignore
|
7 |
|
|
This file documents the end user interface to the GNU command line
|
8 |
|
|
editing features. It is to be an appendix to manuals for programs which
|
9 |
|
|
use these features. There is a document entitled "readline.texinfo"
|
10 |
|
|
which contains both end-user and programmer documentation for the GNU
|
11 |
|
|
Readline Library.
|
12 |
|
|
|
13 |
|
|
Copyright (C) 1988, 1991, 1993, 1996 Free Software Foundation, Inc.
|
14 |
|
|
|
15 |
|
|
Authored by Brian Fox and Chet Ramey.
|
16 |
|
|
|
17 |
|
|
Permission is granted to process this file through Tex and print the
|
18 |
|
|
results, provided the printed document carries copying permission notice
|
19 |
|
|
identical to this one except for the removal of this paragraph (this
|
20 |
|
|
paragraph not being relevant to the printed manual).
|
21 |
|
|
|
22 |
|
|
Permission is granted to make and distribute verbatim copies of this manual
|
23 |
|
|
provided the copyright notice and this permission notice are preserved on
|
24 |
|
|
all copies.
|
25 |
|
|
|
26 |
|
|
Permission is granted to copy and distribute modified versions of this
|
27 |
|
|
manual under the conditions for verbatim copying, provided also that the
|
28 |
|
|
GNU Copyright statement is available to the distributee, and provided that
|
29 |
|
|
the entire resulting derived work is distributed under the terms of a
|
30 |
|
|
permission notice identical to this one.
|
31 |
|
|
|
32 |
|
|
Permission is granted to copy and distribute translations of this manual
|
33 |
|
|
into another language, under the above conditions for modified versions.
|
34 |
|
|
@end ignore
|
35 |
|
|
|
36 |
|
|
@comment If you are including this manual as an appendix, then set the
|
37 |
|
|
@comment variable readline-appendix.
|
38 |
|
|
|
39 |
|
|
@node Command Line Editing
|
40 |
|
|
@chapter Command Line Editing
|
41 |
|
|
|
42 |
|
|
This chapter describes the basic features of the @sc{GNU}
|
43 |
|
|
command line editing interface.
|
44 |
|
|
|
45 |
|
|
@menu
|
46 |
|
|
* Introduction and Notation:: Notation used in this text.
|
47 |
|
|
* Readline Interaction:: The minimum set of commands for editing a line.
|
48 |
|
|
* Readline Init File:: Customizing Readline from a user's view.
|
49 |
|
|
* Bindable Readline Commands:: A description of most of the Readline commands
|
50 |
|
|
available for binding
|
51 |
|
|
* Readline vi Mode:: A short description of how to make Readline
|
52 |
|
|
behave like the vi editor.
|
53 |
|
|
@end menu
|
54 |
|
|
|
55 |
|
|
@node Introduction and Notation
|
56 |
|
|
@section Introduction to Line Editing
|
57 |
|
|
|
58 |
|
|
The following paragraphs describe the notation used to represent
|
59 |
|
|
keystrokes.
|
60 |
|
|
|
61 |
|
|
The text @key{C-k} is read as `Control-K' and describes the character
|
62 |
|
|
produced when the @key{k} key is pressed while the Control key
|
63 |
|
|
is depressed.
|
64 |
|
|
|
65 |
|
|
The text @key{M-k} is read as `Meta-K' and describes the character
|
66 |
|
|
produced when the meta key (if you have one) is depressed, and the @key{k}
|
67 |
|
|
key is pressed. If you do not have a meta key, the identical keystroke
|
68 |
|
|
can be generated by typing @key{ESC} @i{first}, and then typing @key{k}.
|
69 |
|
|
Either process is known as @dfn{metafying} the @key{k} key.
|
70 |
|
|
|
71 |
|
|
The text @key{M-C-k} is read as `Meta-Control-k' and describes the
|
72 |
|
|
character produced by @dfn{metafying} @key{C-k}.
|
73 |
|
|
|
74 |
|
|
In addition, several keys have their own names. Specifically,
|
75 |
|
|
@key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all
|
76 |
|
|
stand for themselves when seen in this text, or in an init file
|
77 |
|
|
(@pxref{Readline Init File}).
|
78 |
|
|
|
79 |
|
|
@node Readline Interaction
|
80 |
|
|
@section Readline Interaction
|
81 |
|
|
@cindex interaction, readline
|
82 |
|
|
|
83 |
|
|
Often during an interactive session you type in a long line of text,
|
84 |
|
|
only to notice that the first word on the line is misspelled. The
|
85 |
|
|
Readline library gives you a set of commands for manipulating the text
|
86 |
|
|
as you type it in, allowing you to just fix your typo, and not forcing
|
87 |
|
|
you to retype the majority of the line. Using these editing commands,
|
88 |
|
|
you move the cursor to the place that needs correction, and delete or
|
89 |
|
|
insert the text of the corrections. Then, when you are satisfied with
|
90 |
|
|
the line, you simply press @key{RETURN}. You do not have to be at the
|
91 |
|
|
end of the line to press @key{RETURN}; the entire line is accepted
|
92 |
|
|
regardless of the location of the cursor within the line.
|
93 |
|
|
|
94 |
|
|
@menu
|
95 |
|
|
* Readline Bare Essentials:: The least you need to know about Readline.
|
96 |
|
|
* Readline Movement Commands:: Moving about the input line.
|
97 |
|
|
* Readline Killing Commands:: How to delete text, and how to get it back!
|
98 |
|
|
* Readline Arguments:: Giving numeric arguments to commands.
|
99 |
|
|
* Searching:: Searching through previous lines.
|
100 |
|
|
@end menu
|
101 |
|
|
|
102 |
|
|
@node Readline Bare Essentials
|
103 |
|
|
@subsection Readline Bare Essentials
|
104 |
|
|
@cindex notation, readline
|
105 |
|
|
@cindex command editing
|
106 |
|
|
@cindex editing command lines
|
107 |
|
|
|
108 |
|
|
In order to enter characters into the line, simply type them. The typed
|
109 |
|
|
character appears where the cursor was, and then the cursor moves one
|
110 |
|
|
space to the right. If you mistype a character, you can use your
|
111 |
|
|
erase character to back up and delete the mistyped character.
|
112 |
|
|
|
113 |
|
|
Sometimes you may miss typing a character that you wanted to type, and
|
114 |
|
|
not notice your error until you have typed several other characters. In
|
115 |
|
|
that case, you can type @key{C-b} to move the cursor to the left, and then
|
116 |
|
|
correct your mistake. Afterwards, you can move the cursor to the right
|
117 |
|
|
with @key{C-f}.
|
118 |
|
|
|
119 |
|
|
When you add text in the middle of a line, you will notice that characters
|
120 |
|
|
to the right of the cursor are `pushed over' to make room for the text
|
121 |
|
|
that you have inserted. Likewise, when you delete text behind the cursor,
|
122 |
|
|
characters to the right of the cursor are `pulled back' to fill in the
|
123 |
|
|
blank space created by the removal of the text. A list of the basic bare
|
124 |
|
|
essentials for editing the text of an input line follows.
|
125 |
|
|
|
126 |
|
|
@table @asis
|
127 |
|
|
@item @key{C-b}
|
128 |
|
|
Move back one character.
|
129 |
|
|
@item @key{C-f}
|
130 |
|
|
Move forward one character.
|
131 |
|
|
@item @key{DEL}
|
132 |
|
|
Delete the character to the left of the cursor.
|
133 |
|
|
@item @key{C-d}
|
134 |
|
|
Delete the character underneath the cursor.
|
135 |
|
|
@item @w{Printing characters}
|
136 |
|
|
Insert the character into the line at the cursor.
|
137 |
|
|
@item @key{C-_}
|
138 |
|
|
Undo the last editing command. You can undo all the way back to an
|
139 |
|
|
empty line.
|
140 |
|
|
@end table
|
141 |
|
|
|
142 |
|
|
@node Readline Movement Commands
|
143 |
|
|
@subsection Readline Movement Commands
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
The above table describes the most basic possible keystrokes that you need
|
147 |
|
|
in order to do editing of the input line. For your convenience, many
|
148 |
|
|
other commands have been added in addition to @key{C-b}, @key{C-f},
|
149 |
|
|
@key{C-d}, and @key{DEL}. Here are some commands for moving more rapidly
|
150 |
|
|
about the line.
|
151 |
|
|
|
152 |
|
|
@table @key
|
153 |
|
|
@item C-a
|
154 |
|
|
Move to the start of the line.
|
155 |
|
|
@item C-e
|
156 |
|
|
Move to the end of the line.
|
157 |
|
|
@item M-f
|
158 |
|
|
Move forward a word, where a word is composed of letters and digits.
|
159 |
|
|
@item M-b
|
160 |
|
|
Move backward a word.
|
161 |
|
|
@item C-l
|
162 |
|
|
Clear the screen, reprinting the current line at the top.
|
163 |
|
|
@end table
|
164 |
|
|
|
165 |
|
|
Notice how @key{C-f} moves forward a character, while @key{M-f} moves
|
166 |
|
|
forward a word. It is a loose convention that control keystrokes
|
167 |
|
|
operate on characters while meta keystrokes operate on words.
|
168 |
|
|
|
169 |
|
|
@node Readline Killing Commands
|
170 |
|
|
@subsection Readline Killing Commands
|
171 |
|
|
|
172 |
|
|
@cindex killing text
|
173 |
|
|
@cindex yanking text
|
174 |
|
|
|
175 |
|
|
@dfn{Killing} text means to delete the text from the line, but to save
|
176 |
|
|
it away for later use, usually by @dfn{yanking} (re-inserting)
|
177 |
|
|
it back into the line.
|
178 |
|
|
If the description for a command says that it `kills' text, then you can
|
179 |
|
|
be sure that you can get the text back in a different (or the same)
|
180 |
|
|
place later.
|
181 |
|
|
|
182 |
|
|
When you use a kill command, the text is saved in a @dfn{kill-ring}.
|
183 |
|
|
Any number of consecutive kills save all of the killed text together, so
|
184 |
|
|
that when you yank it back, you get it all. The kill
|
185 |
|
|
ring is not line specific; the text that you killed on a previously
|
186 |
|
|
typed line is available to be yanked back later, when you are typing
|
187 |
|
|
another line.
|
188 |
|
|
@cindex kill ring
|
189 |
|
|
|
190 |
|
|
Here is the list of commands for killing text.
|
191 |
|
|
|
192 |
|
|
@table @key
|
193 |
|
|
@item C-k
|
194 |
|
|
Kill the text from the current cursor position to the end of the line.
|
195 |
|
|
|
196 |
|
|
@item M-d
|
197 |
|
|
Kill from the cursor to the end of the current word, or if between
|
198 |
|
|
words, to the end of the next word.
|
199 |
|
|
|
200 |
|
|
@item M-DEL
|
201 |
|
|
Kill from the cursor the start of the previous word, or if between
|
202 |
|
|
words, to the start of the previous word.
|
203 |
|
|
|
204 |
|
|
@item C-w
|
205 |
|
|
Kill from the cursor to the previous whitespace. This is different than
|
206 |
|
|
@key{M-DEL} because the word boundaries differ.
|
207 |
|
|
|
208 |
|
|
@end table
|
209 |
|
|
|
210 |
|
|
Here is how to @dfn{yank} the text back into the line. Yanking
|
211 |
|
|
means to copy the most-recently-killed text from the kill buffer.
|
212 |
|
|
|
213 |
|
|
@table @key
|
214 |
|
|
@item C-y
|
215 |
|
|
Yank the most recently killed text back into the buffer at the cursor.
|
216 |
|
|
|
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 @key{C-y} or @key{M-y}.
|
220 |
|
|
@end table
|
221 |
|
|
|
222 |
|
|
@node Readline Arguments
|
223 |
|
|
@subsection Readline Arguments
|
224 |
|
|
|
225 |
|
|
You can pass numeric arguments to Readline commands. Sometimes the
|
226 |
|
|
argument acts as a repeat count, other times it is the @i{sign} of the
|
227 |
|
|
argument that is significant. If you pass a negative argument to a
|
228 |
|
|
command which normally acts in a forward direction, that command will
|
229 |
|
|
act in a backward direction. For example, to kill text back to the
|
230 |
|
|
start of the line, you might type @samp{M-- C-k}.
|
231 |
|
|
|
232 |
|
|
The general way to pass numeric arguments to a command is to type meta
|
233 |
|
|
digits before the command. If the first `digit' typed is a minus
|
234 |
|
|
sign (@key{-}), then the sign of the argument will be negative. Once
|
235 |
|
|
you have typed one meta digit to get the argument started, you can type
|
236 |
|
|
the remainder of the digits, and then the command. For example, to give
|
237 |
|
|
the @key{C-d} command an argument of 10, you could type @samp{M-1 0 C-d}.
|
238 |
|
|
|
239 |
|
|
@node Searching
|
240 |
|
|
@subsection Searching for Commands in the History
|
241 |
|
|
|
242 |
|
|
Readline provides commands for searching through the command history
|
243 |
|
|
@ifset BashFeatures
|
244 |
|
|
(@pxref{Bash History Facilities})
|
245 |
|
|
@end ifset
|
246 |
|
|
for lines containing a specified string.
|
247 |
|
|
There are two search modes: @var{incremental} and @var{non-incremental}.
|
248 |
|
|
|
249 |
|
|
Incremental searches begin before the user has finished typing the
|
250 |
|
|
search string.
|
251 |
|
|
As each character of the search string is typed, Readline displays
|
252 |
|
|
the next entry from the history matching the string typed so far.
|
253 |
|
|
An incremental search requires only as many characters as needed to
|
254 |
|
|
find the desired history entry.
|
255 |
|
|
The characters present in the value of the @var{isearch-terminators} variable
|
256 |
|
|
are used to terminate an incremental search.
|
257 |
|
|
If that variable has not been assigned a value, the @key{ESC} and
|
258 |
|
|
@key{C-J} characters will terminate an incremental search.
|
259 |
|
|
@key{C-g} will abort an incremental search and restore the original line.
|
260 |
|
|
When the search is terminated, the history entry containing the
|
261 |
|
|
search string becomes the current line.
|
262 |
|
|
To find other matching entries in the history list, type @key{C-s} or
|
263 |
|
|
@key{C-r} as appropriate.
|
264 |
|
|
This will search backward or forward in the history for the next
|
265 |
|
|
entry matching the search string typed so far.
|
266 |
|
|
Any other key sequence bound to a Readline command will terminate
|
267 |
|
|
the search and execute that command.
|
268 |
|
|
For instance, a @key{RET} will terminate the search and accept
|
269 |
|
|
the line, thereby executing the command from the history list.
|
270 |
|
|
|
271 |
|
|
Non-incremental searches read the entire search string before starting
|
272 |
|
|
to search for matching history lines. The search string may be
|
273 |
|
|
typed by the user or be part of the contents of the current line.
|
274 |
|
|
|
275 |
|
|
@node Readline Init File
|
276 |
|
|
@section Readline Init File
|
277 |
|
|
@cindex initialization file, readline
|
278 |
|
|
|
279 |
|
|
Although the Readline library comes with a set of @code{emacs}-like
|
280 |
|
|
keybindings installed by default, it is possible to use a different set
|
281 |
|
|
of keybindings.
|
282 |
|
|
Any user can customize programs that use Readline by putting
|
283 |
|
|
commands in an @dfn{inputrc} file in his home directory.
|
284 |
|
|
The name of this
|
285 |
|
|
@ifset BashFeatures
|
286 |
|
|
file is taken from the value of the shell variable @code{INPUTRC}. If
|
287 |
|
|
@end ifset
|
288 |
|
|
@ifclear BashFeatures
|
289 |
|
|
file is taken from the value of the environment variable @code{INPUTRC}. If
|
290 |
|
|
@end ifclear
|
291 |
|
|
that variable is unset, the default is @file{~/.inputrc}.
|
292 |
|
|
|
293 |
|
|
When a program which uses the Readline library starts up, the
|
294 |
|
|
init file is read, and the key bindings are set.
|
295 |
|
|
|
296 |
|
|
In addition, the @code{C-x C-r} command re-reads this init file, thus
|
297 |
|
|
incorporating any changes that you might have made to it.
|
298 |
|
|
|
299 |
|
|
@menu
|
300 |
|
|
* Readline Init File Syntax:: Syntax for the commands in the inputrc file.
|
301 |
|
|
|
302 |
|
|
* Conditional Init Constructs:: Conditional key bindings in the inputrc file.
|
303 |
|
|
|
304 |
|
|
* Sample Init File:: An example inputrc file.
|
305 |
|
|
@end menu
|
306 |
|
|
|
307 |
|
|
@node Readline Init File Syntax
|
308 |
|
|
@subsection Readline Init File Syntax
|
309 |
|
|
|
310 |
|
|
There are only a few basic constructs allowed in the
|
311 |
|
|
Readline init file. Blank lines are ignored.
|
312 |
|
|
Lines beginning with a @samp{#} are comments.
|
313 |
|
|
Lines beginning with a @samp{$} indicate conditional
|
314 |
|
|
constructs (@pxref{Conditional Init Constructs}). Other lines
|
315 |
|
|
denote variable settings and key bindings.
|
316 |
|
|
|
317 |
|
|
@table @asis
|
318 |
|
|
@item Variable Settings
|
319 |
|
|
You can modify the run-time behavior of Readline by
|
320 |
|
|
altering the values of variables in Readline
|
321 |
|
|
using the @code{set} command within the init file. Here is how to
|
322 |
|
|
change from the default Emacs-like key binding to use
|
323 |
|
|
@code{vi} line editing commands:
|
324 |
|
|
|
325 |
|
|
@example
|
326 |
|
|
set editing-mode vi
|
327 |
|
|
@end example
|
328 |
|
|
|
329 |
|
|
A great deal of run-time behavior is changeable with the following
|
330 |
|
|
variables.
|
331 |
|
|
|
332 |
|
|
@table @code
|
333 |
|
|
|
334 |
|
|
@item bell-style
|
335 |
|
|
@vindex bell-style
|
336 |
|
|
Controls what happens when Readline wants to ring the terminal bell.
|
337 |
|
|
If set to @samp{none}, Readline never rings the bell. If set to
|
338 |
|
|
@samp{visible}, Readline uses a visible bell if one is available.
|
339 |
|
|
If set to @samp{audible} (the default), Readline attempts to ring
|
340 |
|
|
the terminal's bell.
|
341 |
|
|
|
342 |
|
|
@item comment-begin
|
343 |
|
|
@vindex comment-begin
|
344 |
|
|
The string to insert at the beginning of the line when the
|
345 |
|
|
@code{insert-comment} command is executed. The default value
|
346 |
|
|
is @code{"#"}.
|
347 |
|
|
|
348 |
|
|
@item completion-ignore-case
|
349 |
|
|
If set to @samp{on}, Readline performs filename matching and completion
|
350 |
|
|
in a case-insensitive fashion.
|
351 |
|
|
The default value is @samp{off}.
|
352 |
|
|
|
353 |
|
|
@item completion-query-items
|
354 |
|
|
@vindex completion-query-items
|
355 |
|
|
The number of possible completions that determines when the user is
|
356 |
|
|
asked whether he wants to see the list of possibilities. If the
|
357 |
|
|
number of possible completions is greater than this value,
|
358 |
|
|
Readline will ask the user whether or not he wishes to view
|
359 |
|
|
them; otherwise, they are simply listed. The default limit is
|
360 |
|
|
@code{100}.
|
361 |
|
|
|
362 |
|
|
@item convert-meta
|
363 |
|
|
@vindex convert-meta
|
364 |
|
|
If set to @samp{on}, Readline will convert characters with the
|
365 |
|
|
eighth bit set to an ASCII key sequence by stripping the eighth
|
366 |
|
|
bit and prepending an @key{ESC} character, converting them to a
|
367 |
|
|
meta-prefixed key sequence. The default value is @samp{on}.
|
368 |
|
|
|
369 |
|
|
@item disable-completion
|
370 |
|
|
@vindex disable-completion
|
371 |
|
|
If set to @samp{On}, Readline will inhibit word completion.
|
372 |
|
|
Completion characters will be inserted into the line as if they had
|
373 |
|
|
been mapped to @code{self-insert}. The default is @samp{off}.
|
374 |
|
|
|
375 |
|
|
@item editing-mode
|
376 |
|
|
@vindex editing-mode
|
377 |
|
|
The @code{editing-mode} variable controls which default set of
|
378 |
|
|
key bindings is used. By default, Readline starts up in Emacs editing
|
379 |
|
|
mode, where the keystrokes are most similar to Emacs. This variable can be
|
380 |
|
|
set to either @samp{emacs} or @samp{vi}.
|
381 |
|
|
|
382 |
|
|
@item enable-keypad
|
383 |
|
|
@vindex enable-keypad
|
384 |
|
|
When set to @samp{on}, Readline will try to enable the application
|
385 |
|
|
keypad when it is called. Some systems need this to enable the
|
386 |
|
|
arrow keys. The default is @samp{off}.
|
387 |
|
|
|
388 |
|
|
@item expand-tilde
|
389 |
|
|
@vindex expand-tilde
|
390 |
|
|
If set to @samp{on}, tilde expansion is performed when Readline
|
391 |
|
|
attempts word completion. The default is @samp{off}.
|
392 |
|
|
|
393 |
|
|
@item horizontal-scroll-mode
|
394 |
|
|
@vindex horizontal-scroll-mode
|
395 |
|
|
This variable can be set to either @samp{on} or @samp{off}. Setting it
|
396 |
|
|
to @samp{on} means that the text of the lines being edited will scroll
|
397 |
|
|
horizontally on a single screen line when they are longer than the width
|
398 |
|
|
of the screen, instead of wrapping onto a new screen line. By default,
|
399 |
|
|
this variable is set to @samp{off}.
|
400 |
|
|
|
401 |
|
|
@item input-meta
|
402 |
|
|
@vindex input-meta
|
403 |
|
|
@vindex meta-flag
|
404 |
|
|
If set to @samp{on}, Readline will enable eight-bit input (it
|
405 |
|
|
will not strip the eighth bit from the characters it reads),
|
406 |
|
|
regardless of what the terminal claims it can support. The
|
407 |
|
|
default value is @samp{off}. The name @code{meta-flag} is a
|
408 |
|
|
synonym for this variable.
|
409 |
|
|
|
410 |
|
|
@item isearch-terminators
|
411 |
|
|
@vindex isearch-terminators
|
412 |
|
|
The string of characters that should terminate an incremental search without
|
413 |
|
|
subsequently executing the character as a command (@pxref{Searching}).
|
414 |
|
|
If this variable has not been given a value, the characters @key{ESC} and
|
415 |
|
|
@key{C-J} will terminate an incremental search.
|
416 |
|
|
|
417 |
|
|
@item keymap
|
418 |
|
|
@vindex keymap
|
419 |
|
|
Sets Readline's idea of the current keymap for key binding commands.
|
420 |
|
|
Acceptable @code{keymap} names are
|
421 |
|
|
@code{emacs},
|
422 |
|
|
@code{emacs-standard},
|
423 |
|
|
@code{emacs-meta},
|
424 |
|
|
@code{emacs-ctlx},
|
425 |
|
|
@code{vi},
|
426 |
|
|
@code{vi-command}, and
|
427 |
|
|
@code{vi-insert}.
|
428 |
|
|
@code{vi} is equivalent to @code{vi-command}; @code{emacs} is
|
429 |
|
|
equivalent to @code{emacs-standard}. The default value is @code{emacs}.
|
430 |
|
|
The value of the @code{editing-mode} variable also affects the
|
431 |
|
|
default keymap.
|
432 |
|
|
|
433 |
|
|
@item mark-directories
|
434 |
|
|
If set to @samp{on}, completed directory names have a slash
|
435 |
|
|
appended. The default is @samp{on}.
|
436 |
|
|
|
437 |
|
|
@item mark-modified-lines
|
438 |
|
|
@vindex mark-modified-lines
|
439 |
|
|
This variable, when set to @samp{on}, causes Readline to display an
|
440 |
|
|
asterisk (@samp{*}) at the start of history lines which have been modified.
|
441 |
|
|
This variable is @samp{off} by default.
|
442 |
|
|
|
443 |
|
|
@item output-meta
|
444 |
|
|
@vindex output-meta
|
445 |
|
|
If set to @samp{on}, Readline will display characters with the
|
446 |
|
|
eighth bit set directly rather than as a meta-prefixed escape
|
447 |
|
|
sequence. The default is @samp{off}.
|
448 |
|
|
|
449 |
|
|
@item print-completions-horizontally
|
450 |
|
|
If set to @samp{on}, Readline will display completions with matches
|
451 |
|
|
sorted horizontally in alphabetical order, rather than down the screen.
|
452 |
|
|
The default is @samp{off}.
|
453 |
|
|
|
454 |
|
|
@item show-all-if-ambiguous
|
455 |
|
|
@vindex show-all-if-ambiguous
|
456 |
|
|
This alters the default behavior of the completion functions. If
|
457 |
|
|
set to @samp{on},
|
458 |
|
|
words which have more than one possible completion cause the
|
459 |
|
|
matches to be listed immediately instead of ringing the bell.
|
460 |
|
|
The default value is @samp{off}.
|
461 |
|
|
|
462 |
|
|
@item visible-stats
|
463 |
|
|
@vindex visible-stats
|
464 |
|
|
If set to @samp{on}, a character denoting a file's type
|
465 |
|
|
is appended to the filename when listing possible
|
466 |
|
|
completions. The default is @samp{off}.
|
467 |
|
|
|
468 |
|
|
@end table
|
469 |
|
|
|
470 |
|
|
@item Key Bindings
|
471 |
|
|
The syntax for controlling key bindings in the init file is
|
472 |
|
|
simple. First you have to know the name of the command that you
|
473 |
|
|
want to change. The following sections contain tables of the command
|
474 |
|
|
name, the default keybinding, if any, and a short description of what
|
475 |
|
|
the command does.
|
476 |
|
|
|
477 |
|
|
Once you know the name of the command, simply place the name of the key
|
478 |
|
|
you wish to bind the command to, a colon, and then the name of the
|
479 |
|
|
command on a line in the init file. The name of the key
|
480 |
|
|
can be expressed in different ways, depending on which is most
|
481 |
|
|
comfortable for you.
|
482 |
|
|
|
483 |
|
|
@table @asis
|
484 |
|
|
@item @w{@var{keyname}: @var{function-name} or @var{macro}}
|
485 |
|
|
@var{keyname} is the name of a key spelled out in English. For example:
|
486 |
|
|
@example
|
487 |
|
|
Control-u: universal-argument
|
488 |
|
|
Meta-Rubout: backward-kill-word
|
489 |
|
|
Control-o: "> output"
|
490 |
|
|
@end example
|
491 |
|
|
|
492 |
|
|
In the above example, @key{C-u} is bound to the function
|
493 |
|
|
@code{universal-argument}, and @key{C-o} is bound to run the macro
|
494 |
|
|
expressed on the right hand side (that is, to insert the text
|
495 |
|
|
@samp{> output} into the line).
|
496 |
|
|
|
497 |
|
|
@item @w{"@var{keyseq}": @var{function-name} or @var{macro}}
|
498 |
|
|
@var{keyseq} differs from @var{keyname} above in that strings
|
499 |
|
|
denoting an entire key sequence can be specified, by placing
|
500 |
|
|
the key sequence in double quotes. Some GNU Emacs style key
|
501 |
|
|
escapes can be used, as in the following example, but the
|
502 |
|
|
special character names are not recognized.
|
503 |
|
|
|
504 |
|
|
@example
|
505 |
|
|
"\C-u": universal-argument
|
506 |
|
|
"\C-x\C-r": re-read-init-file
|
507 |
|
|
"\e[11~": "Function Key 1"
|
508 |
|
|
@end example
|
509 |
|
|
|
510 |
|
|
In the above example, @key{C-u} is bound to the function
|
511 |
|
|
@code{universal-argument} (just as it was in the first example),
|
512 |
|
|
@samp{@key{C-x} @key{C-r}} is bound to the function @code{re-read-init-file},
|
513 |
|
|
and @samp{@key{ESC} @key{[} @key{1} @key{1} @key{~}} is bound to insert
|
514 |
|
|
the text @samp{Function Key 1}.
|
515 |
|
|
|
516 |
|
|
@end table
|
517 |
|
|
|
518 |
|
|
The following GNU Emacs style escape sequences are available when
|
519 |
|
|
specifying key sequences:
|
520 |
|
|
|
521 |
|
|
@table @code
|
522 |
|
|
@item @kbd{\C-}
|
523 |
|
|
control prefix
|
524 |
|
|
@item @kbd{\M-}
|
525 |
|
|
meta prefix
|
526 |
|
|
@item @kbd{\e}
|
527 |
|
|
an escape character
|
528 |
|
|
@item @kbd{\\}
|
529 |
|
|
backslash
|
530 |
|
|
@item @kbd{\"}
|
531 |
|
|
@key{"}
|
532 |
|
|
@item @kbd{\'}
|
533 |
|
|
@key{'}
|
534 |
|
|
@end table
|
535 |
|
|
|
536 |
|
|
In addition to the GNU Emacs style escape sequences, a second
|
537 |
|
|
set of backslash escapes is available:
|
538 |
|
|
|
539 |
|
|
@table @code
|
540 |
|
|
@item \a
|
541 |
|
|
alert (bell)
|
542 |
|
|
@item \b
|
543 |
|
|
backspace
|
544 |
|
|
@item \d
|
545 |
|
|
delete
|
546 |
|
|
@item \f
|
547 |
|
|
form feed
|
548 |
|
|
@item \n
|
549 |
|
|
newline
|
550 |
|
|
@item \r
|
551 |
|
|
carriage return
|
552 |
|
|
@item \t
|
553 |
|
|
horizontal tab
|
554 |
|
|
@item \v
|
555 |
|
|
vertical tab
|
556 |
|
|
@item \@var{nnn}
|
557 |
|
|
the character whose ASCII code is the octal value @var{nnn}
|
558 |
|
|
(one to three digits)
|
559 |
|
|
@item \x@var{nnn}
|
560 |
|
|
the character whose ASCII code is the hexadecimal value @var{nnn}
|
561 |
|
|
(one to three digits)
|
562 |
|
|
@end table
|
563 |
|
|
|
564 |
|
|
When entering the text of a macro, single or double quotes must
|
565 |
|
|
be used to indicate a macro definition.
|
566 |
|
|
Unquoted text is assumed to be a function name.
|
567 |
|
|
In the macro body, the backslash escapes described above are expanded.
|
568 |
|
|
Backslash will quote any other character in the macro text,
|
569 |
|
|
including @samp{"} and @samp{'}.
|
570 |
|
|
For example, the following binding will make @samp{C-x \}
|
571 |
|
|
insert a single @samp{\} into the line:
|
572 |
|
|
@example
|
573 |
|
|
"\C-x\\": "\\"
|
574 |
|
|
@end example
|
575 |
|
|
|
576 |
|
|
@end table
|
577 |
|
|
|
578 |
|
|
@node Conditional Init Constructs
|
579 |
|
|
@subsection Conditional Init Constructs
|
580 |
|
|
|
581 |
|
|
Readline implements a facility similar in spirit to the conditional
|
582 |
|
|
compilation features of the C preprocessor which allows key
|
583 |
|
|
bindings and variable settings to be performed as the result
|
584 |
|
|
of tests. There are four parser directives used.
|
585 |
|
|
|
586 |
|
|
@table @code
|
587 |
|
|
@item $if
|
588 |
|
|
The @code{$if} construct allows bindings to be made based on the
|
589 |
|
|
editing mode, the terminal being used, or the application using
|
590 |
|
|
Readline. The text of the test extends to the end of the line;
|
591 |
|
|
no characters are required to isolate it.
|
592 |
|
|
|
593 |
|
|
@table @code
|
594 |
|
|
@item mode
|
595 |
|
|
The @code{mode=} form of the @code{$if} directive is used to test
|
596 |
|
|
whether Readline is in @code{emacs} or @code{vi} mode.
|
597 |
|
|
This may be used in conjunction
|
598 |
|
|
with the @samp{set keymap} command, for instance, to set bindings in
|
599 |
|
|
the @code{emacs-standard} and @code{emacs-ctlx} keymaps only if
|
600 |
|
|
Readline is starting out in @code{emacs} mode.
|
601 |
|
|
|
602 |
|
|
@item term
|
603 |
|
|
The @code{term=} form may be used to include terminal-specific
|
604 |
|
|
key bindings, perhaps to bind the key sequences output by the
|
605 |
|
|
terminal's function keys. The word on the right side of the
|
606 |
|
|
@samp{=} is tested against both the full name of the terminal and
|
607 |
|
|
the portion of the terminal name before the first @samp{-}. This
|
608 |
|
|
allows @code{sun} to match both @code{sun} and @code{sun-cmd},
|
609 |
|
|
for instance.
|
610 |
|
|
|
611 |
|
|
@item application
|
612 |
|
|
The @var{application} construct is used to include
|
613 |
|
|
application-specific settings. Each program using the Readline
|
614 |
|
|
library sets the @var{application name}, and you can test for it.
|
615 |
|
|
This could be used to bind key sequences to functions useful for
|
616 |
|
|
a specific program. For instance, the following command adds a
|
617 |
|
|
key sequence that quotes the current or previous word in Bash:
|
618 |
|
|
@example
|
619 |
|
|
$if Bash
|
620 |
|
|
# Quote the current or previous word
|
621 |
|
|
"\C-xq": "\eb\"\ef\""
|
622 |
|
|
$endif
|
623 |
|
|
@end example
|
624 |
|
|
@end table
|
625 |
|
|
|
626 |
|
|
@item $endif
|
627 |
|
|
This command, as seen in the previous example, terminates an
|
628 |
|
|
@code{$if} command.
|
629 |
|
|
|
630 |
|
|
@item $else
|
631 |
|
|
Commands in this branch of the @code{$if} directive are executed if
|
632 |
|
|
the test fails.
|
633 |
|
|
|
634 |
|
|
@item $include
|
635 |
|
|
This directive takes a single filename as an argument and reads commands
|
636 |
|
|
and bindings from that file.
|
637 |
|
|
@example
|
638 |
|
|
$include /etc/inputrc
|
639 |
|
|
@end example
|
640 |
|
|
@end table
|
641 |
|
|
|
642 |
|
|
@node Sample Init File
|
643 |
|
|
@subsection Sample Init File
|
644 |
|
|
|
645 |
|
|
Here is an example of an inputrc file. This illustrates key
|
646 |
|
|
binding, variable assignment, and conditional syntax.
|
647 |
|
|
|
648 |
|
|
@example
|
649 |
|
|
@page
|
650 |
|
|
# This file controls the behaviour of line input editing for
|
651 |
|
|
# programs that use the Gnu Readline library. Existing programs
|
652 |
|
|
# include FTP, Bash, and Gdb.
|
653 |
|
|
#
|
654 |
|
|
# You can re-read the inputrc file with C-x C-r.
|
655 |
|
|
# Lines beginning with '#' are comments.
|
656 |
|
|
#
|
657 |
|
|
# First, include any systemwide bindings and variable assignments from
|
658 |
|
|
# /etc/Inputrc
|
659 |
|
|
$include /etc/Inputrc
|
660 |
|
|
|
661 |
|
|
#
|
662 |
|
|
# Set various bindings for emacs mode.
|
663 |
|
|
|
664 |
|
|
set editing-mode emacs
|
665 |
|
|
|
666 |
|
|
$if mode=emacs
|
667 |
|
|
|
668 |
|
|
Meta-Control-h: backward-kill-word Text after the function name is ignored
|
669 |
|
|
|
670 |
|
|
#
|
671 |
|
|
# Arrow keys in keypad mode
|
672 |
|
|
#
|
673 |
|
|
#"\M-OD": backward-char
|
674 |
|
|
#"\M-OC": forward-char
|
675 |
|
|
#"\M-OA": previous-history
|
676 |
|
|
#"\M-OB": next-history
|
677 |
|
|
#
|
678 |
|
|
# Arrow keys in ANSI mode
|
679 |
|
|
#
|
680 |
|
|
"\M-[D": backward-char
|
681 |
|
|
"\M-[C": forward-char
|
682 |
|
|
"\M-[A": previous-history
|
683 |
|
|
"\M-[B": next-history
|
684 |
|
|
#
|
685 |
|
|
# Arrow keys in 8 bit keypad mode
|
686 |
|
|
#
|
687 |
|
|
#"\M-\C-OD": backward-char
|
688 |
|
|
#"\M-\C-OC": forward-char
|
689 |
|
|
#"\M-\C-OA": previous-history
|
690 |
|
|
#"\M-\C-OB": next-history
|
691 |
|
|
#
|
692 |
|
|
# Arrow keys in 8 bit ANSI mode
|
693 |
|
|
#
|
694 |
|
|
#"\M-\C-[D": backward-char
|
695 |
|
|
#"\M-\C-[C": forward-char
|
696 |
|
|
#"\M-\C-[A": previous-history
|
697 |
|
|
#"\M-\C-[B": next-history
|
698 |
|
|
|
699 |
|
|
C-q: quoted-insert
|
700 |
|
|
|
701 |
|
|
$endif
|
702 |
|
|
|
703 |
|
|
# An old-style binding. This happens to be the default.
|
704 |
|
|
TAB: complete
|
705 |
|
|
|
706 |
|
|
# Macros that are convenient for shell interaction
|
707 |
|
|
$if Bash
|
708 |
|
|
# edit the path
|
709 |
|
|
"\C-xp": "PATH=$@{PATH@}\e\C-e\C-a\ef\C-f"
|
710 |
|
|
# prepare to type a quoted word -- insert open and close double quotes
|
711 |
|
|
# and move to just after the open quote
|
712 |
|
|
"\C-x\"": "\"\"\C-b"
|
713 |
|
|
# insert a backslash (testing backslash escapes in sequences and macros)
|
714 |
|
|
"\C-x\\": "\\"
|
715 |
|
|
# Quote the current or previous word
|
716 |
|
|
"\C-xq": "\eb\"\ef\""
|
717 |
|
|
# Add a binding to refresh the line, which is unbound
|
718 |
|
|
"\C-xr": redraw-current-line
|
719 |
|
|
# Edit variable on current line.
|
720 |
|
|
"\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
|
721 |
|
|
$endif
|
722 |
|
|
|
723 |
|
|
# use a visible bell if one is available
|
724 |
|
|
set bell-style visible
|
725 |
|
|
|
726 |
|
|
# don't strip characters to 7 bits when reading
|
727 |
|
|
set input-meta on
|
728 |
|
|
|
729 |
|
|
# allow iso-latin1 characters to be inserted rather than converted to
|
730 |
|
|
# prefix-meta sequences
|
731 |
|
|
set convert-meta off
|
732 |
|
|
|
733 |
|
|
# display characters with the eighth bit set directly rather than
|
734 |
|
|
# as meta-prefixed characters
|
735 |
|
|
set output-meta on
|
736 |
|
|
|
737 |
|
|
# if there are more than 150 possible completions for a word, ask the
|
738 |
|
|
# user if he wants to see all of them
|
739 |
|
|
set completion-query-items 150
|
740 |
|
|
|
741 |
|
|
# For FTP
|
742 |
|
|
$if Ftp
|
743 |
|
|
"\C-xg": "get \M-?"
|
744 |
|
|
"\C-xt": "put \M-?"
|
745 |
|
|
"\M-.": yank-last-arg
|
746 |
|
|
$endif
|
747 |
|
|
@end example
|
748 |
|
|
|
749 |
|
|
@node Bindable Readline Commands
|
750 |
|
|
@section Bindable Readline Commands
|
751 |
|
|
|
752 |
|
|
@menu
|
753 |
|
|
* Commands For Moving:: Moving about the line.
|
754 |
|
|
* Commands For History:: Getting at previous lines.
|
755 |
|
|
* Commands For Text:: Commands for changing text.
|
756 |
|
|
* Commands For Killing:: Commands for killing and yanking.
|
757 |
|
|
* Numeric Arguments:: Specifying numeric arguments, repeat counts.
|
758 |
|
|
* Commands For Completion:: Getting Readline to do the typing for you.
|
759 |
|
|
* Keyboard Macros:: Saving and re-executing typed characters
|
760 |
|
|
* Miscellaneous Commands:: Other miscellaneous commands.
|
761 |
|
|
@end menu
|
762 |
|
|
|
763 |
|
|
This section describes Readline commands that may be bound to key
|
764 |
|
|
sequences.
|
765 |
|
|
|
766 |
|
|
@node Commands For Moving
|
767 |
|
|
@subsection Commands For Moving
|
768 |
|
|
@ftable @code
|
769 |
|
|
@item beginning-of-line (C-a)
|
770 |
|
|
Move to the start of the current line.
|
771 |
|
|
|
772 |
|
|
@item end-of-line (C-e)
|
773 |
|
|
Move to the end of the line.
|
774 |
|
|
|
775 |
|
|
@item forward-char (C-f)
|
776 |
|
|
Move forward a character.
|
777 |
|
|
|
778 |
|
|
@item backward-char (C-b)
|
779 |
|
|
Move back a character.
|
780 |
|
|
|
781 |
|
|
@item forward-word (M-f)
|
782 |
|
|
Move forward to the end of the next word. Words are composed of
|
783 |
|
|
letters and digits.
|
784 |
|
|
|
785 |
|
|
@item backward-word (M-b)
|
786 |
|
|
Move back to the start of this, or the previous, word. Words are
|
787 |
|
|
composed of letters and digits.
|
788 |
|
|
|
789 |
|
|
@item clear-screen (C-l)
|
790 |
|
|
Clear the screen and redraw the current line,
|
791 |
|
|
leaving the current line at the top of the screen.
|
792 |
|
|
|
793 |
|
|
@item redraw-current-line ()
|
794 |
|
|
Refresh the current line. By default, this is unbound.
|
795 |
|
|
|
796 |
|
|
@end ftable
|
797 |
|
|
|
798 |
|
|
@node Commands For History
|
799 |
|
|
@subsection Commands For Manipulating The History
|
800 |
|
|
|
801 |
|
|
@ftable @code
|
802 |
|
|
@item accept-line (Newline, Return)
|
803 |
|
|
@ifset BashFeatures
|
804 |
|
|
Accept the line regardless of where the cursor is. If this line is
|
805 |
|
|
non-empty, add it to the history list according to the setting of
|
806 |
|
|
the @code{HISTCONTROL} and @code{HISTIGNORE} variables.
|
807 |
|
|
If this line was a history line, then restore the history line to its
|
808 |
|
|
original state.
|
809 |
|
|
@end ifset
|
810 |
|
|
@ifclear BashFeatures
|
811 |
|
|
Accept the line regardless of where the cursor is. If this line is
|
812 |
|
|
non-empty, add it to the history list. If this line was a history
|
813 |
|
|
line, then restore the history line to its original state.
|
814 |
|
|
@end ifclear
|
815 |
|
|
|
816 |
|
|
@item previous-history (C-p)
|
817 |
|
|
Move `up' through the history list.
|
818 |
|
|
|
819 |
|
|
@item next-history (C-n)
|
820 |
|
|
Move `down' through the history list.
|
821 |
|
|
|
822 |
|
|
@item beginning-of-history (M-<)
|
823 |
|
|
Move to the first line in the history.
|
824 |
|
|
|
825 |
|
|
@item end-of-history (M->)
|
826 |
|
|
Move to the end of the input history, i.e., the line currently
|
827 |
|
|
being entered.
|
828 |
|
|
|
829 |
|
|
@item reverse-search-history (C-r)
|
830 |
|
|
Search backward starting at the current line and moving `up' through
|
831 |
|
|
the history as necessary. This is an incremental search.
|
832 |
|
|
|
833 |
|
|
@item forward-search-history (C-s)
|
834 |
|
|
Search forward starting at the current line and moving `down' through
|
835 |
|
|
the the history as necessary. This is an incremental search.
|
836 |
|
|
|
837 |
|
|
@item non-incremental-reverse-search-history (M-p)
|
838 |
|
|
Search backward starting at the current line and moving `up'
|
839 |
|
|
through the history as necessary using a non-incremental search
|
840 |
|
|
for a string supplied by the user.
|
841 |
|
|
|
842 |
|
|
@item non-incremental-forward-search-history (M-n)
|
843 |
|
|
Search forward starting at the current line and moving `down'
|
844 |
|
|
through the the history as necessary using a non-incremental search
|
845 |
|
|
for a string supplied by the user.
|
846 |
|
|
|
847 |
|
|
@item history-search-forward ()
|
848 |
|
|
Search forward through the history for the string of characters
|
849 |
|
|
between the start of the current line and the current cursor
|
850 |
|
|
position (the @var{point}). This is a non-incremental search. By
|
851 |
|
|
default, this command is unbound.
|
852 |
|
|
|
853 |
|
|
@item history-search-backward ()
|
854 |
|
|
Search backward through the history for the string of characters
|
855 |
|
|
between the start of the current line and the point. This
|
856 |
|
|
is a non-incremental search. By default, this command is unbound.
|
857 |
|
|
|
858 |
|
|
@item yank-nth-arg (M-C-y)
|
859 |
|
|
Insert the first argument to the previous command (usually
|
860 |
|
|
the second word on the previous line). With an argument @var{n},
|
861 |
|
|
insert the @var{n}th word from the previous command (the words
|
862 |
|
|
in the previous command begin with word 0). A negative argument
|
863 |
|
|
inserts the @var{n}th word from the end of the previous command.
|
864 |
|
|
|
865 |
|
|
@item yank-last-arg (M-., M-_)
|
866 |
|
|
Insert last argument to the previous command (the last word of the
|
867 |
|
|
previous history entry). With an
|
868 |
|
|
argument, behave exactly like @code{yank-nth-arg}.
|
869 |
|
|
Successive calls to @code{yank-last-arg} move back through the history
|
870 |
|
|
list, inserting the last argument of each line in turn.
|
871 |
|
|
|
872 |
|
|
@end ftable
|
873 |
|
|
|
874 |
|
|
@node Commands For Text
|
875 |
|
|
@subsection Commands For Changing Text
|
876 |
|
|
|
877 |
|
|
@ftable @code
|
878 |
|
|
@item delete-char (C-d)
|
879 |
|
|
Delete the character under the cursor. If the cursor is at the
|
880 |
|
|
beginning of the line, there are no characters in the line, and
|
881 |
|
|
the last character typed was not bound to @code{delete-char}, then
|
882 |
|
|
return @code{EOF}.
|
883 |
|
|
|
884 |
|
|
@item backward-delete-char (Rubout)
|
885 |
|
|
Delete the character behind the cursor. A numeric argument means
|
886 |
|
|
to kill the characters instead of deleting them.
|
887 |
|
|
|
888 |
|
|
@item forward-backward-delete-char ()
|
889 |
|
|
Delete the character under the cursor, unless the cursor is at the
|
890 |
|
|
end of the line, in which case the character behind the cursor is
|
891 |
|
|
deleted. By default, this is not bound to a key.
|
892 |
|
|
|
893 |
|
|
@item quoted-insert (C-q, C-v)
|
894 |
|
|
Add the next character typed to the line verbatim. This is
|
895 |
|
|
how to insert key sequences like @key{C-q}, for example.
|
896 |
|
|
|
897 |
|
|
@ifclear BashFeatures
|
898 |
|
|
@item tab-insert (M-TAB)
|
899 |
|
|
Insert a tab character.
|
900 |
|
|
@end ifclear
|
901 |
|
|
|
902 |
|
|
@item self-insert (a, b, A, 1, !, ...)
|
903 |
|
|
Insert yourself.
|
904 |
|
|
|
905 |
|
|
@item transpose-chars (C-t)
|
906 |
|
|
Drag the character before the cursor forward over
|
907 |
|
|
the character at the cursor, moving the
|
908 |
|
|
cursor forward as well. If the insertion point
|
909 |
|
|
is at the end of the line, then this
|
910 |
|
|
transposes the last two characters of the line.
|
911 |
|
|
Negative arguments don't work.
|
912 |
|
|
|
913 |
|
|
@item transpose-words (M-t)
|
914 |
|
|
Drag the word behind the cursor past the word in front of the cursor
|
915 |
|
|
moving the cursor over that word as well.
|
916 |
|
|
|
917 |
|
|
@item upcase-word (M-u)
|
918 |
|
|
Uppercase the current (or following) word. With a negative argument,
|
919 |
|
|
uppercase the previous word, but do not move the cursor.
|
920 |
|
|
|
921 |
|
|
@item downcase-word (M-l)
|
922 |
|
|
Lowercase the current (or following) word. With a negative argument,
|
923 |
|
|
lowercase the previous word, but do not move the cursor.
|
924 |
|
|
|
925 |
|
|
@item capitalize-word (M-c)
|
926 |
|
|
Capitalize the current (or following) word. With a negative argument,
|
927 |
|
|
capitalize the previous word, but do not move the cursor.
|
928 |
|
|
|
929 |
|
|
@end ftable
|
930 |
|
|
|
931 |
|
|
@node Commands For Killing
|
932 |
|
|
@subsection Killing And Yanking
|
933 |
|
|
|
934 |
|
|
@ftable @code
|
935 |
|
|
|
936 |
|
|
@item kill-line (C-k)
|
937 |
|
|
Kill the text from the current cursor position to the end of the line.
|
938 |
|
|
|
939 |
|
|
@item backward-kill-line (C-x Rubout)
|
940 |
|
|
Kill backward to the beginning of the line.
|
941 |
|
|
|
942 |
|
|
@item unix-line-discard (C-u)
|
943 |
|
|
Kill backward from the cursor to the beginning of the current line.
|
944 |
|
|
The killed text is saved on the kill-ring.
|
945 |
|
|
|
946 |
|
|
@item kill-whole-line ()
|
947 |
|
|
Kill all characters on the current line, no matter where the
|
948 |
|
|
cursor is. By default, this is unbound.
|
949 |
|
|
|
950 |
|
|
@item kill-word (M-d)
|
951 |
|
|
Kill from the cursor to the end of the current word, or if between
|
952 |
|
|
words, to the end of the next word. Word boundaries are the same
|
953 |
|
|
as @code{forward-word}.
|
954 |
|
|
|
955 |
|
|
@item backward-kill-word (M-DEL)
|
956 |
|
|
Kill the word behind the cursor. Word boundaries are the same
|
957 |
|
|
as @code{backward-word}.
|
958 |
|
|
|
959 |
|
|
@item unix-word-rubout (C-w)
|
960 |
|
|
Kill the word behind the cursor, using white space as a word
|
961 |
|
|
boundary. The killed text is saved on the kill-ring.
|
962 |
|
|
|
963 |
|
|
@item delete-horizontal-space ()
|
964 |
|
|
Delete all spaces and tabs around point. By default, this is unbound.
|
965 |
|
|
|
966 |
|
|
@item kill-region ()
|
967 |
|
|
Kill the text between the point and the @emph{mark} (saved
|
968 |
|
|
cursor position). This text is referred to as the @var{region}.
|
969 |
|
|
By default, this command is unbound.
|
970 |
|
|
|
971 |
|
|
@item copy-region-as-kill ()
|
972 |
|
|
Copy the text in the region to the kill buffer, so it can be yanked
|
973 |
|
|
right away. By default, this command is unbound.
|
974 |
|
|
|
975 |
|
|
@item copy-backward-word ()
|
976 |
|
|
Copy the word before point to the kill buffer.
|
977 |
|
|
The word boundaries are the same as @code{backward-word}.
|
978 |
|
|
By default, this command is unbound.
|
979 |
|
|
|
980 |
|
|
@item copy-forward-word ()
|
981 |
|
|
Copy the word following point to the kill buffer.
|
982 |
|
|
The word boundaries are the same as @code{forward-word}.
|
983 |
|
|
By default, this command is unbound.
|
984 |
|
|
|
985 |
|
|
@item yank (C-y)
|
986 |
|
|
Yank the top of the kill ring into the buffer at the current
|
987 |
|
|
cursor position.
|
988 |
|
|
|
989 |
|
|
@item yank-pop (M-y)
|
990 |
|
|
Rotate the kill-ring, and yank the new top. You can only do this if
|
991 |
|
|
the prior command is yank or yank-pop.
|
992 |
|
|
@end ftable
|
993 |
|
|
|
994 |
|
|
@node Numeric Arguments
|
995 |
|
|
@subsection Specifying Numeric Arguments
|
996 |
|
|
@ftable @code
|
997 |
|
|
|
998 |
|
|
@item digit-argument (M-0, M-1, ... M--)
|
999 |
|
|
Add this digit to the argument already accumulating, or start a new
|
1000 |
|
|
argument. @key{M--} starts a negative argument.
|
1001 |
|
|
|
1002 |
|
|
@item universal-argument ()
|
1003 |
|
|
This is another way to specify an argument.
|
1004 |
|
|
If this command is followed by one or more digits, optionally with a
|
1005 |
|
|
leading minus sign, those digits define the argument.
|
1006 |
|
|
If the command is followed by digits, executing @code{universal-argument}
|
1007 |
|
|
again ends the numeric argument, but is otherwise ignored.
|
1008 |
|
|
As a special case, if this command is immediately followed by a
|
1009 |
|
|
character that is neither a digit or minus sign, the argument count
|
1010 |
|
|
for the next command is multiplied by four.
|
1011 |
|
|
The argument count is initially one, so executing this function the
|
1012 |
|
|
first time makes the argument count four, a second time makes the
|
1013 |
|
|
argument count sixteen, and so on.
|
1014 |
|
|
By default, this is not bound to a key.
|
1015 |
|
|
@end ftable
|
1016 |
|
|
|
1017 |
|
|
@node Commands For Completion
|
1018 |
|
|
@subsection Letting Readline Type For You
|
1019 |
|
|
|
1020 |
|
|
@ftable @code
|
1021 |
|
|
@item complete (TAB)
|
1022 |
|
|
Attempt to do completion on the text before the cursor. This is
|
1023 |
|
|
application-specific. Generally, if you are typing a filename
|
1024 |
|
|
argument, you can do filename completion; if you are typing a command,
|
1025 |
|
|
you can do command completion; if you are typing in a symbol to GDB, you
|
1026 |
|
|
can do symbol name completion; if you are typing in a variable to Bash,
|
1027 |
|
|
you can do variable name completion, and so on.
|
1028 |
|
|
@ifset BashFeatures
|
1029 |
|
|
Bash attempts completion treating the text as a variable (if the
|
1030 |
|
|
text begins with @samp{$}), username (if the text begins with
|
1031 |
|
|
@samp{~}), hostname (if the text begins with @samp{@@}), or
|
1032 |
|
|
command (including aliases and functions) in turn. If none
|
1033 |
|
|
of these produces a match, filename completion is attempted.
|
1034 |
|
|
@end ifset
|
1035 |
|
|
|
1036 |
|
|
@item possible-completions (M-?)
|
1037 |
|
|
List the possible completions of the text before the cursor.
|
1038 |
|
|
|
1039 |
|
|
@item insert-completions (M-*)
|
1040 |
|
|
Insert all completions of the text before point that would have
|
1041 |
|
|
been generated by @code{possible-completions}.
|
1042 |
|
|
|
1043 |
|
|
@item menu-complete ()
|
1044 |
|
|
Similar to @code{complete}, but replaces the word to be completed
|
1045 |
|
|
with a single match from the list of possible completions.
|
1046 |
|
|
Repeated execution of @code{menu-complete} steps through the list
|
1047 |
|
|
of possible completions, inserting each match in turn.
|
1048 |
|
|
At the end of the list of completions, the bell is rung and the
|
1049 |
|
|
original text is restored.
|
1050 |
|
|
An argument of @var{n} moves @var{n} positions forward in the list
|
1051 |
|
|
of matches; a negative argument may be used to move backward
|
1052 |
|
|
through the list.
|
1053 |
|
|
This command is intended to be bound to @code{TAB}, but is unbound
|
1054 |
|
|
by default.
|
1055 |
|
|
|
1056 |
|
|
@item delete-char-or-list ()
|
1057 |
|
|
Deletes the character under the cursor if not at the beginning or
|
1058 |
|
|
end of the line (like @code{delete-char}).
|
1059 |
|
|
If at the end of the line, behaves identically to
|
1060 |
|
|
@code{possible-completions}.
|
1061 |
|
|
This command is unbound by default.
|
1062 |
|
|
|
1063 |
|
|
@ifset BashFeatures
|
1064 |
|
|
@item complete-filename (M-/)
|
1065 |
|
|
Attempt filename completion on the text before point.
|
1066 |
|
|
|
1067 |
|
|
@item possible-filename-completions (C-x /)
|
1068 |
|
|
List the possible completions of the text before point,
|
1069 |
|
|
treating it as a filename.
|
1070 |
|
|
|
1071 |
|
|
@item complete-username (M-~)
|
1072 |
|
|
Attempt completion on the text before point, treating
|
1073 |
|
|
it as a username.
|
1074 |
|
|
|
1075 |
|
|
@item possible-username-completions (C-x ~)
|
1076 |
|
|
List the possible completions of the text before point,
|
1077 |
|
|
treating it as a username.
|
1078 |
|
|
|
1079 |
|
|
@item complete-variable (M-$)
|
1080 |
|
|
Attempt completion on the text before point, treating
|
1081 |
|
|
it as a shell variable.
|
1082 |
|
|
|
1083 |
|
|
@item possible-variable-completions (C-x $)
|
1084 |
|
|
List the possible completions of the text before point,
|
1085 |
|
|
treating it as a shell variable.
|
1086 |
|
|
|
1087 |
|
|
@item complete-hostname (M-@@)
|
1088 |
|
|
Attempt completion on the text before point, treating
|
1089 |
|
|
it as a hostname.
|
1090 |
|
|
|
1091 |
|
|
@item possible-hostname-completions (C-x @@)
|
1092 |
|
|
List the possible completions of the text before point,
|
1093 |
|
|
treating it as a hostname.
|
1094 |
|
|
|
1095 |
|
|
@item complete-command (M-!)
|
1096 |
|
|
Attempt completion on the text before point, treating
|
1097 |
|
|
it as a command name. Command completion attempts to
|
1098 |
|
|
match the text against aliases, reserved words, shell
|
1099 |
|
|
functions, shell builtins, and finally executable filenames,
|
1100 |
|
|
in that order.
|
1101 |
|
|
|
1102 |
|
|
@item possible-command-completions (C-x !)
|
1103 |
|
|
List the possible completions of the text before point,
|
1104 |
|
|
treating it as a command name.
|
1105 |
|
|
|
1106 |
|
|
@item dynamic-complete-history (M-TAB)
|
1107 |
|
|
Attempt completion on the text before point, comparing
|
1108 |
|
|
the text against lines from the history list for possible
|
1109 |
|
|
completion matches.
|
1110 |
|
|
|
1111 |
|
|
@item complete-into-braces (M-@{)
|
1112 |
|
|
Perform filename completion and return the list of possible completions
|
1113 |
|
|
enclosed within braces so the list is available to the shell
|
1114 |
|
|
(@pxref{Brace Expansion}).
|
1115 |
|
|
|
1116 |
|
|
@end ifset
|
1117 |
|
|
@end ftable
|
1118 |
|
|
|
1119 |
|
|
@node Keyboard Macros
|
1120 |
|
|
@subsection Keyboard Macros
|
1121 |
|
|
@ftable @code
|
1122 |
|
|
|
1123 |
|
|
@item start-kbd-macro (C-x ()
|
1124 |
|
|
Begin saving the characters typed into the current keyboard macro.
|
1125 |
|
|
|
1126 |
|
|
@item end-kbd-macro (C-x ))
|
1127 |
|
|
Stop saving the characters typed into the current keyboard macro
|
1128 |
|
|
and save the definition.
|
1129 |
|
|
|
1130 |
|
|
@item call-last-kbd-macro (C-x e)
|
1131 |
|
|
Re-execute the last keyboard macro defined, by making the characters
|
1132 |
|
|
in the macro appear as if typed at the keyboard.
|
1133 |
|
|
|
1134 |
|
|
@end ftable
|
1135 |
|
|
|
1136 |
|
|
@node Miscellaneous Commands
|
1137 |
|
|
@subsection Some Miscellaneous Commands
|
1138 |
|
|
@ftable @code
|
1139 |
|
|
|
1140 |
|
|
@item re-read-init-file (C-x C-r)
|
1141 |
|
|
Read in the contents of the inputrc file, and incorporate
|
1142 |
|
|
any bindings or variable assignments found there.
|
1143 |
|
|
|
1144 |
|
|
@item abort (C-g)
|
1145 |
|
|
Abort the current editing command and
|
1146 |
|
|
ring the terminal's bell (subject to the setting of
|
1147 |
|
|
@code{bell-style}).
|
1148 |
|
|
|
1149 |
|
|
@item do-uppercase-version (M-a, M-b, M-@var{x}, @dots{})
|
1150 |
|
|
If the metafied character @var{x} is lowercase, run the command
|
1151 |
|
|
that is bound to the corresponding uppercase character.
|
1152 |
|
|
|
1153 |
|
|
@item prefix-meta (ESC)
|
1154 |
|
|
Make the next character typed be metafied. This is for keyboards
|
1155 |
|
|
without a meta key. Typing @samp{ESC f} is equivalent to typing
|
1156 |
|
|
@samp{M-f}.
|
1157 |
|
|
|
1158 |
|
|
@item undo (C-_, C-x C-u)
|
1159 |
|
|
Incremental undo, separately remembered for each line.
|
1160 |
|
|
|
1161 |
|
|
@item revert-line (M-r)
|
1162 |
|
|
Undo all changes made to this line. This is like executing the @code{undo}
|
1163 |
|
|
command enough times to get back to the beginning.
|
1164 |
|
|
|
1165 |
|
|
@ifset BashFeatures
|
1166 |
|
|
@item tilde-expand (M-&)
|
1167 |
|
|
@end ifset
|
1168 |
|
|
@ifclear BashFeatures
|
1169 |
|
|
@item tilde-expand (M-~)
|
1170 |
|
|
@end ifclear
|
1171 |
|
|
Perform tilde expansion on the current word.
|
1172 |
|
|
|
1173 |
|
|
@item set-mark (C-@@)
|
1174 |
|
|
Set the mark to the current point. If a
|
1175 |
|
|
numeric argument is supplied, the mark is set to that position.
|
1176 |
|
|
|
1177 |
|
|
@item exchange-point-and-mark (C-x C-x)
|
1178 |
|
|
Swap the point with the mark. The current cursor position is set to
|
1179 |
|
|
the saved position, and the old cursor position is saved as the mark.
|
1180 |
|
|
|
1181 |
|
|
@item character-search (C-])
|
1182 |
|
|
A character is read and point is moved to the next occurrence of that
|
1183 |
|
|
character. A negative count searches for previous occurrences.
|
1184 |
|
|
|
1185 |
|
|
@item character-search-backward (M-C-])
|
1186 |
|
|
A character is read and point is moved to the previous occurrence
|
1187 |
|
|
of that character. A negative count searches for subsequent
|
1188 |
|
|
occurrences.
|
1189 |
|
|
|
1190 |
|
|
@item insert-comment (M-#)
|
1191 |
|
|
The value of the @code{comment-begin}
|
1192 |
|
|
variable is inserted at the beginning of the current line,
|
1193 |
|
|
and the line is accepted as if a newline had been typed.
|
1194 |
|
|
@ifset BashFeatures
|
1195 |
|
|
This makes the current line a shell comment.
|
1196 |
|
|
@end ifset
|
1197 |
|
|
|
1198 |
|
|
@item dump-functions ()
|
1199 |
|
|
Print all of the functions and their key bindings to the
|
1200 |
|
|
Readline output stream. If a numeric argument is supplied,
|
1201 |
|
|
the output is formatted in such a way that it can be made part
|
1202 |
|
|
of an @var{inputrc} file. This command is unbound by default.
|
1203 |
|
|
|
1204 |
|
|
@item dump-variables ()
|
1205 |
|
|
Print all of the settable variables and their values to the
|
1206 |
|
|
Readline output stream. If a numeric argument is supplied,
|
1207 |
|
|
the output is formatted in such a way that it can be made part
|
1208 |
|
|
of an @var{inputrc} file. This command is unbound by default.
|
1209 |
|
|
|
1210 |
|
|
@item dump-macros ()
|
1211 |
|
|
Print all of the Readline key sequences bound to macros and the
|
1212 |
|
|
strings they ouput. If a numeric argument is supplied,
|
1213 |
|
|
the output is formatted in such a way that it can be made part
|
1214 |
|
|
of an @var{inputrc} file. This command is unbound by default.
|
1215 |
|
|
|
1216 |
|
|
@ifset BashFeatures
|
1217 |
|
|
@item glob-expand-word (C-x *)
|
1218 |
|
|
The word before point is treated as a pattern for pathname expansion,
|
1219 |
|
|
and the list of matching file names is inserted, replacing the word.
|
1220 |
|
|
|
1221 |
|
|
@item glob-list-expansions (C-x g)
|
1222 |
|
|
The list of expansions that would have been generated by
|
1223 |
|
|
@code{glob-expand-word} is displayed, and the line is redrawn.
|
1224 |
|
|
|
1225 |
|
|
@item display-shell-version (C-x C-v)
|
1226 |
|
|
Display version information about the current instance of Bash.
|
1227 |
|
|
|
1228 |
|
|
@item shell-expand-line (M-C-e)
|
1229 |
|
|
Expand the line as the shell does.
|
1230 |
|
|
This performs alias and history expansion as well as all of the shell
|
1231 |
|
|
word expansions (@pxref{Shell Expansions}).
|
1232 |
|
|
|
1233 |
|
|
@item history-expand-line (M-^)
|
1234 |
|
|
Perform history expansion on the current line.
|
1235 |
|
|
|
1236 |
|
|
@item magic-space ()
|
1237 |
|
|
Perform history expansion on the current line and insert a space
|
1238 |
|
|
(@pxref{History Interaction}).
|
1239 |
|
|
|
1240 |
|
|
@item alias-expand-line ()
|
1241 |
|
|
Perform alias expansion on the current line (@pxref{Aliases}).
|
1242 |
|
|
|
1243 |
|
|
@item history-and-alias-expand-line ()
|
1244 |
|
|
Perform history and alias expansion on the current line.
|
1245 |
|
|
|
1246 |
|
|
@item insert-last-argument (M-., M-_)
|
1247 |
|
|
A synonym for @code{yank-last-arg}.
|
1248 |
|
|
|
1249 |
|
|
@item operate-and-get-next (C-o)
|
1250 |
|
|
Accept the current line for execution and fetch the next line
|
1251 |
|
|
relative to the current line from the history for editing. Any
|
1252 |
|
|
argument is ignored.
|
1253 |
|
|
|
1254 |
|
|
@item emacs-editing-mode (C-e)
|
1255 |
|
|
When in @code{vi} editing mode, this causes a switch back to
|
1256 |
|
|
@code{emacs} editing mode, as if the command @samp{set -o emacs} had
|
1257 |
|
|
been executed.
|
1258 |
|
|
|
1259 |
|
|
@end ifset
|
1260 |
|
|
|
1261 |
|
|
@end ftable
|
1262 |
|
|
|
1263 |
|
|
@node Readline vi Mode
|
1264 |
|
|
@section Readline vi Mode
|
1265 |
|
|
|
1266 |
|
|
While the Readline library does not have a full set of @code{vi}
|
1267 |
|
|
editing functions, it does contain enough to allow simple editing
|
1268 |
|
|
of the line. The Readline @code{vi} mode behaves as specified in
|
1269 |
|
|
the @sc{POSIX} 1003.2 standard.
|
1270 |
|
|
|
1271 |
|
|
@ifset BashFeatures
|
1272 |
|
|
In order to switch interactively between @code{emacs} and @code{vi}
|
1273 |
|
|
editing modes, use the @samp{set -o emacs} and @samp{set -o vi}
|
1274 |
|
|
commands (@pxref{The Set Builtin}).
|
1275 |
|
|
@end ifset
|
1276 |
|
|
@ifclear BashFeatures
|
1277 |
|
|
In order to switch interactively between @code{emacs} and @code{vi}
|
1278 |
|
|
editing modes, use the command M-C-j (toggle-editing-mode).
|
1279 |
|
|
@end ifclear
|
1280 |
|
|
The Readline default is @code{emacs} mode.
|
1281 |
|
|
|
1282 |
|
|
When you enter a line in @code{vi} mode, you are already placed in
|
1283 |
|
|
`insertion' mode, as if you had typed an @samp{i}. Pressing @key{ESC}
|
1284 |
|
|
switches you into `command' mode, where you can edit the text of the
|
1285 |
|
|
line with the standard @code{vi} movement keys, move to previous
|
1286 |
|
|
history lines with @samp{k} and subsequent lines with @samp{j}, and
|
1287 |
|
|
so forth.
|