GNU Info

Info Node: (zsh.info)Overview

(zsh.info)Overview


Next: Event Designators Up: History Expansion
Enter node , (file) or (file)node

Overview
--------

A history expansion begins with the first character of the histchars
parameter, which is `!' by default, and may occur anywhere on the
command line; history expansions do not nest.  The `!' can be escaped
with `\' or can be enclosed between a pair of single quotes ('') to
suppress its special meaning.  Double quotes will _not_ work for this.
Following this history character is an optional event designator (Note:
Event Designators) and then an optional word designator (Note: Word
Designators); if neither of these designators is present, no history
expansion occurs.

Input lines containing history expansions are echoed after being
expanded, but before any other expansions take place and before the
command is executed.  It is this expanded form that is recorded as the
history event for later references.

By default, a history reference with no event designator refers to the
same event as any preceding history reference on that command line; if
it is the only history reference in a command, it refers to the previous
command.  However, if the option CSH_JUNKIE_HISTORY is set, then every
history reference with no event specification _always_ refers to the
previous command.

For example, `!' is the event designator for the previous command, so
`!!:1' always refers to the first word of the previous command, and
`!!$' always refers to the last word of the previous command.  With
CSH_JUNKIE_HISTORY set, then `!:1' and `!$' function in the same manner
as `!!:1' and `!!$', respectively.  Conversely, if CSH_JUNKIE_HISTORY
is unset, then `!:1' and `!$' refer to the first and last words,
respectively, of the same event referenced by the nearest other history
reference preceding them on the current command line, or to the
previous command if there is no preceding reference.

The character sequence `^FOO^BAR' (where `^' is actually the second
character of the histchars parameter) repeats the last command,
replacing the string FOO with BAR.  More precisely, the sequence
`^FOO^BAR^' is synonymous with `!!:s^FOO^BAR^', hence other modifiers
(see Note: Modifiers) may follow the final `^'.

If the shell encounters the character sequence `!"'  in the input, the
history mechanism is temporarily disabled until the current list (see
Note: Shell Grammar) is fully parsed.  The `!"' is removed from the
input, and any subsequent `!' characters have no special significance.

A less convenient but more comprehensible form of command history
support is provided by the fc builtin.


automatically generated by info2www version 1.2.2.9