2 This file documents the user interface to the GNU History library.
4 Copyright (C) 1988, 1991 Free Software Foundation, Inc.
5 Authored by Brian Fox and Chet Ramey.
7 Permission is granted to make and distribute verbatim copies of this manual
8 provided the copyright notice and this permission notice are preserved on
11 Permission is granted to process this file through Tex and print the
12 results, provided the printed document carries copying permission notice
13 identical to this one except for the removal of this paragraph (this
14 paragraph not being relevant to the printed manual).
16 Permission is granted to copy and distribute modified versions of this
17 manual under the conditions for verbatim copying, provided also that the
18 GNU Copyright statement is available to the distributee, and provided that
19 the entire resulting derived work is distributed under the terms of a
20 permission notice identical to this one.
22 Permission is granted to copy and distribute translations of this manual
23 into another language, under the above conditions for modified versions.
26 @node Using History Interactively
27 @chapter Using History Interactively
30 This chapter describes how to use the GNU History Library interactively,
31 from a user's standpoint. It should be considered a user's guide. For
32 information on using the GNU History Library in your own programs,
33 see the GNU Readline Library Manual.
36 This chapter describes how to use the GNU History Library interactively,
37 from a user's standpoint. It should be considered a user's guide. For
38 information on using the GNU History Library in your own programs,
39 @pxref{Programming with GNU History}.
43 * History Interaction:: What it feels like using History as a user.
46 @node History Interaction
47 @section History Interaction
50 The History library provides a history expansion feature that is similar
51 to the history expansion provided by @code{csh}. The following text
52 describes the syntax used to manipulate the history information.
54 History expansion takes place in two parts. The first is to determine
55 which line from the previous history should be used during substitution.
56 The second is to select portions of that line for inclusion into the
57 current one. The line selected from the previous history is called the
58 @dfn{event}, and the portions of that line that are acted upon are
59 called @dfn{words}. The line is broken into words in the same fashion
60 that Bash does, so that several English (or Unix) words
61 surrounded by quotes are considered as one word.
64 * Event Designators:: How to specify which history line to use.
65 * Word Designators:: Specifying which words are of interest.
66 * Modifiers:: Modifying the results of substitution.
69 @node Event Designators
70 @subsection Event Designators
71 @cindex event designators
73 An event designator is a reference to a command line entry in the
75 @cindex history events
80 Start a history substitution, except when followed by a space, tab,
81 the end of the line, @key{=} or @key{(}.
84 Refer to the previous command. This is a synonym for @code{!-1}.
87 Refer to command line @var{n}.
90 Refer to the command @var{n} lines back.
93 Refer to the most recent command starting with @var{string}.
95 @item @code{!?string}[@code{?}]
96 Refer to the most recent command containing @var{string}.
99 The entire command line typed so far.
101 @item @code{^string1^string2^}
102 Quick Substitution. Repeat the last command, replacing @var{string1}
103 with @var{string2}. Equivalent to
104 @code{!!:s/string1/string2/}.
108 @node Word Designators
109 @subsection Word Designators
111 A @key{:} separates the event specification from the word designator. It
112 can be omitted if the word designator begins with a @key{^}, @key{$},
113 @key{*} or @key{%}. Words are numbered from the beginning of the line,
114 with the first word being denoted by a 0 (zero).
119 The @code{0}th word. For many applications, this is the command word.
125 The first argument; that is, word 1.
131 The word matched by the most recent @code{?string?} search.
134 A range of words; @code{-@var{y}} abbreviates @code{0-@var{y}}.
137 All of the words, except the @code{0}th. This is a synonym for @code{1-$}.
138 It is not an error to use @key{*} if there is just one word in the event;
139 the empty string is returned in that case.
142 Abbreviates @code{x-$}
145 Abbreviates @code{x-$} like @code{x*}, but omits the last word.
150 @subsection Modifiers
152 After the optional word designator, you can add a sequence of one or more
153 of the following modifiers, each preceded by a @key{:}.
158 Remove a trailing pathname component, leaving only the head.
161 Remove a trailing suffix of the form @samp{.}@var{suffix}, leaving the basename.
164 Remove all but the trailing suffix.
167 Remove all leading pathname components, leaving the tail.
170 Print the new command but do not execute it.
174 Quote the substituted words, escaping further substitutions.
177 Quote the substituted words as with @code{q},
178 but break into words at spaces, tabs, and newlines.
182 Substitute @var{new} for the first occurrence of @var{old} in the
183 event line. Any delimiter may be used in place of @key{/}.
184 The delimiter may be quoted in @var{old} and @var{new}
185 with a single backslash. If @key{&} appears in @var{new},
186 it is replaced by @var{old}. A single backslash will quote
187 the @key{&}. The final delimiter is optional if it is the last
188 character on the input line.
191 Repeat the previous substitution.
194 Cause changes to be applied over the entire event line. Used in
195 conjunction with @code{s}, as in @code{gs/old/new/}, or with