|
version 1.1.1.1, 2014/07/30 08:16:45
|
version 1.1.1.2, 2021/03/17 01:01:01
|
|
Line 1
|
Line 1
|
| @ignore |
@ignore |
| This file documents the user interface to the GNU History library. |
This file documents the user interface to the GNU History library. |
| |
|
| Copyright (C) 1988--2014 Free Software Foundation, Inc. | Copyright (C) 1988--2020 Free Software Foundation, Inc. |
| Authored by Brian Fox and Chet Ramey. |
Authored by Brian Fox and Chet Ramey. |
| |
|
| Permission is granted to make and distribute verbatim copies of this manual |
Permission is granted to make and distribute verbatim copies of this manual |
|
Line 102 associated with each history entry is written to the h
|
Line 102 associated with each history entry is written to the h
|
| marked with the history comment character. |
marked with the history comment character. |
| When the history file is read, lines beginning with the history |
When the history file is read, lines beginning with the history |
| comment character followed immediately by a digit are interpreted |
comment character followed immediately by a digit are interpreted |
| as timestamps for the previous history line. | as timestamps for the following history entry. |
| |
|
| The builtin command @code{fc} may be used to list or edit and re-execute |
The builtin command @code{fc} may be used to list or edit and re-execute |
| a portion of the history list. |
a portion of the history list. |
|
Line 124 The @code{lithist}
|
Line 124 The @code{lithist}
|
| shell option causes the shell to save the command with embedded newlines |
shell option causes the shell to save the command with embedded newlines |
| instead of semicolons. |
instead of semicolons. |
| The @code{shopt} builtin is used to set these options. |
The @code{shopt} builtin is used to set these options. |
| @xref{Bash Builtins}, for a description of @code{shopt}. | @xref{The Shopt Builtin}, for a description of @code{shopt}. |
| |
|
| @node Bash History Builtins |
@node Bash History Builtins |
| @section Bash History Builtins |
@section Bash History Builtins |
|
Line 149 Both @var{first} and
|
Line 149 Both @var{first} and
|
| @var{last} may be specified as a string (to locate the most recent |
@var{last} may be specified as a string (to locate the most recent |
| command beginning with that string) or as a number (an index into the |
command beginning with that string) or as a number (an index into the |
| history list, where a negative number is used as an offset from the |
history list, where a negative number is used as an offset from the |
| current command number). If @var{last} is not specified it is set to | current command number). |
| @var{first}. If @var{first} is not specified it is set to the previous | |
| | When listing, a @var{first} or @var{last} of 0 is equivalent to -1 |
| | and -0 is equivalent to the current command (usually the @code{fc} |
| | command); |
| | otherwise 0 is equivalent to -1 and -0 is invalid. |
| | |
| | If @var{last} is not specified, it is set to |
| | @var{first}. If @var{first} is not specified, it is set to the previous |
| command for editing and @minus{}16 for listing. If the @option{-l} flag is |
command for editing and @minus{}16 for listing. If the @option{-l} flag is |
| given, the commands are listed on standard output. The @option{-n} flag |
given, the commands are listed on standard output. The @option{-n} flag |
| suppresses the command numbers when listing. The @option{-r} flag |
suppresses the command numbers when listing. The @option{-r} flag |
|
Line 164 When editing is complete, the edited commands are echo
|
Line 171 When editing is complete, the edited commands are echo
|
| |
|
| In the second form, @var{command} is re-executed after each instance |
In the second form, @var{command} is re-executed after each instance |
| of @var{pat} in the selected command is replaced by @var{rep}. |
of @var{pat} in the selected command is replaced by @var{rep}. |
| @var{command} is intepreted the same as @var{first} above. | @var{command} is interpreted the same as @var{first} above. |
| |
|
| A useful alias to use with the @code{fc} command is @code{r='fc -s'}, so |
A useful alias to use with the @code{fc} command is @code{r='fc -s'}, so |
| that typing @samp{r cc} runs the last command beginning with @code{cc} |
that typing @samp{r cc} runs the last command beginning with @code{cc} |
|
Line 176 and typing @samp{r} re-executes the last command (@pxr
|
Line 183 and typing @samp{r} re-executes the last command (@pxr
|
| history [@var{n}] |
history [@var{n}] |
| history -c |
history -c |
| history -d @var{offset} |
history -d @var{offset} |
| |
history -d @var{start}-@var{end} |
| history [-anrw] [@var{filename}] |
history [-anrw] [@var{filename}] |
| history -ps @var{arg} |
history -ps @var{arg} |
| @end example |
@end example |
|
Line 198 with the other options to replace the history list com
|
Line 206 with the other options to replace the history list com
|
| |
|
| @item -d @var{offset} |
@item -d @var{offset} |
| Delete the history entry at position @var{offset}. |
Delete the history entry at position @var{offset}. |
| @var{offset} should be specified as it appears when the history is | If @var{offset} is positive, it should be specified as it appears when |
| displayed. | the history is displayed. |
| | If @var{offset} is negative, it is interpreted as relative to one greater |
| | than the last history position, so negative indices count back from the |
| | end of the history, and an index of @samp{-1} refers to the current |
| | @code{history -d} command. |
| |
|
| |
@item -d @var{start}-@var{end} |
| |
Delete the history entries between positions @var{start} and @var{end}, |
| |
inclusive. Positive and negative values for @var{start} and @var{end} |
| |
are interpreted as described above. |
| |
|
| @item -a |
@item -a |
| Append the new | Append the new history lines to the history file. |
| history lines (history lines entered since the beginning of the | These are history lines entered since the beginning of the current |
| current Bash session) to the history file. | Bash session, but not already appended to the history file. |
| |
|
| @item -n |
@item -n |
| Append the history lines not already read from the history file |
Append the history lines not already read from the history file |
|
Line 249 the input stream, making it easy to repeat commands, i
|
Line 266 the input stream, making it easy to repeat commands, i
|
| arguments to a previous command into the current input line, or |
arguments to a previous command into the current input line, or |
| fix errors in previous commands quickly. |
fix errors in previous commands quickly. |
| |
|
| |
@ifset BashFeatures |
| |
History expansion is performed immediately after a complete line |
| |
is read, before the shell breaks it into words, and is performed |
| |
on each line individually. Bash attempts to inform the history |
| |
expansion functions about quoting still in effect from previous lines. |
| |
@end ifset |
| |
|
| History expansion takes place in two parts. The first is to determine |
History expansion takes place in two parts. The first is to determine |
| which line from the history list should be used during substitution. |
which line from the history list should be used during substitution. |
| The second is to select portions of that line for inclusion into the |
The second is to select portions of that line for inclusion into the |
|
Line 260 that Bash does, so that several words
|
Line 284 that Bash does, so that several words
|
| surrounded by quotes are considered one word. |
surrounded by quotes are considered one word. |
| History expansions are introduced by the appearance of the |
History expansions are introduced by the appearance of the |
| history expansion character, which is @samp{!} by default. |
history expansion character, which is @samp{!} by default. |
| |
|
| |
History expansion implements shell-like quoting conventions: |
| |
a backslash can be used to remove the special handling for the next character; |
| |
single quotes enclose verbatim sequences of characters, and can be used to |
| |
inhibit history expansion; |
| |
and characters enclosed within double quotes may be subject to history |
| |
expansion, since backslash can escape the history expansion character, |
| |
but single quotes may not, since they are not treated specially within |
| |
double quotes. |
| |
|
| @ifset BashFeatures |
@ifset BashFeatures |
| Only @samp{\} and @samp{'} may be used to escape the history expansion | When using the shell, only @samp{\} and @samp{'} may be used to escape the |
| character. | history expansion character, but the history expansion character is |
| | also treated as quoted if it immediately precedes the closing double quote |
| | in a double-quoted string. |
| @end ifset |
@end ifset |
| |
|
| @ifset BashFeatures |
@ifset BashFeatures |
| Several shell options settable with the @code{shopt} |
Several shell options settable with the @code{shopt} |
| builtin (@pxref{Bash Builtins}) may be used to tailor | builtin (@pxref{The Shopt Builtin}) may be used to tailor |
| the behavior of history expansion. If the |
the behavior of history expansion. If the |
| @code{histverify} shell option is enabled, and Readline |
@code{histverify} shell option is enabled, and Readline |
| is being used, history substitutions are not immediately passed to |
is being used, history substitutions are not immediately passed to |
|
Line 341 containing @var{string}.
|
Line 377 containing @var{string}.
|
| The trailing |
The trailing |
| @samp{?} may be omitted if the @var{string} is followed immediately by |
@samp{?} may be omitted if the @var{string} is followed immediately by |
| a newline. |
a newline. |
| |
If @var{string} is missing, the string from the most recent search is used; |
| |
it is an error if there is no previous search string. |
| |
|
| @item @code{^@var{string1}^@var{string2}^} |
@item @code{^@var{string1}^@var{string2}^} |
| Quick Substitution. Repeat the last command, replacing @var{string1} |
Quick Substitution. Repeat the last command, replacing @var{string1} |
| with @var{string2}. Equivalent to |
with @var{string2}. Equivalent to |
| @code{!!:s/@var{string1}/@var{string2}/}. | @code{!!:s^@var{string1}^@var{string2}^}. |
| |
|
| @item @code{!#} |
@item @code{!#} |
| The entire command line typed so far. |
The entire command line typed so far. |
|
Line 397 The first argument; that is, word 1.
|
Line 435 The first argument; that is, word 1.
|
| The last argument. |
The last argument. |
| |
|
| @item % |
@item % |
| The word matched by the most recent @samp{?@var{string}?} search. | The first word matched by the most recent @samp{?@var{string}?} search, |
| | if the search string begins with a character that is part of a word. |
| |
|
| @item @var{x}-@var{y} |
@item @var{x}-@var{y} |
| A range of words; @samp{-@var{y}} abbreviates @samp{0-@var{y}}. |
A range of words; @samp{-@var{y}} abbreviates @samp{0-@var{y}}. |
|
Line 412 Abbreviates @samp{@var{x}-$}
|
Line 451 Abbreviates @samp{@var{x}-$}
|
| |
|
| @item @var{x}- |
@item @var{x}- |
| Abbreviates @samp{@var{x}-$} like @samp{@var{x}*}, but omits the last word. |
Abbreviates @samp{@var{x}-$} like @samp{@var{x}*}, but omits the last word. |
| |
If @samp{x} is missing, it defaults to 0. |
| |
|
| @end table |
@end table |
| |
|
|
Line 423 previous command is used as the event.
|
Line 463 previous command is used as the event.
|
| |
|
| After the optional word designator, you can add a sequence of one or more |
After the optional word designator, you can add a sequence of one or more |
| of the following modifiers, each preceded by a @samp{:}. |
of the following modifiers, each preceded by a @samp{:}. |
| |
These modify, or edit, the word or words selected from the history event. |
| |
|
| @table @code |
@table @code |
| |
|
|
Line 449 Quote the substituted words, escaping further substitu
|
Line 490 Quote the substituted words, escaping further substitu
|
| @item x |
@item x |
| Quote the substituted words as with @samp{q}, |
Quote the substituted words as with @samp{q}, |
| but break into words at spaces, tabs, and newlines. |
but break into words at spaces, tabs, and newlines. |
| |
The @samp{q} and @samp{x} modifiers are mutually exclusive; the last one |
| |
supplied is used. |
| @end ifset |
@end ifset |
| |
|
| @item s/@var{old}/@var{new}/ |
@item s/@var{old}/@var{new}/ |
| Substitute @var{new} for the first occurrence of @var{old} in the |
Substitute @var{new} for the first occurrence of @var{old} in the |
| event line. Any delimiter may be used in place of @samp{/}. | event line. |
| | Any character may be used as the delimiter in place of @samp{/}. |
| The delimiter may be quoted in @var{old} and @var{new} |
The delimiter may be quoted in @var{old} and @var{new} |
| with a single backslash. If @samp{&} appears in @var{new}, |
with a single backslash. If @samp{&} appears in @var{new}, |
| it is replaced by @var{old}. A single backslash will quote |
it is replaced by @var{old}. A single backslash will quote |
| the @samp{&}. The final delimiter is optional if it is the last | the @samp{&}. |
| | If @var{old} is null, it is set to the last @var{old} |
| | substituted, or, if no previous history substitutions took place, |
| | the last @var{string} |
| | in a !?@var{string}@code{[?]} |
| | search. |
| | If @var{new} is is null, each matching @var{old} is deleted. |
| | The final delimiter is optional if it is the last |
| character on the input line. |
character on the input line. |
| |
|
| @item & |
@item & |
|
Line 470 conjunction with @samp{s}, as in @code{gs/@var{old}/@v
|
Line 521 conjunction with @samp{s}, as in @code{gs/@var{old}/@v
|
| or with @samp{&}. |
or with @samp{&}. |
| |
|
| @item G |
@item G |
| Apply the following @samp{s} modifier once to each word in the event. | Apply the following @samp{s} or @samp{&} modifier once to each word |
| | in the event. |
| |
|
| @end table |
@end table |