!is the default
! may be quoted out with a
/ or single
quotes, but not double quotes.
Sometimes you might need to use a lot of literal
your command line. (IE, you don't want them interpreted as history
expansions.) As an alternative to quoting each literal
!, you can put the
!" two-character sequence
somewhere on the command line. Then, all
!'s on the
command line appearing after
!" will be
taken as literal
!'s. Note that the
silently discarded by zsh before further processing.
4. A colon can be omitted if the word designator begins with a `^', `$', `*', `-' or `%'.
Note that a
% word designator will only work when used as
!:% , or
!?str?:% , and
only when used after a
!? expansion. Anything else will
result in an error, although the error may not be the most obvious
It is possible to type in a history reference without giving an event
!:$ is an example.
Since such a history reference doesn't refer to an event directly,
zsh makes it refer to the same event as the previous history reference
on the current command-line. (Read that last sentence again, it will make
In the following line:
echo !-3 !:^ !:1*
!:^ doesn't refer to a specific event by itself.
However, the previous history reference,
to the event three entries before the current command line.
!:^ also refers to that same event.
!:^ could've been the first history reference
on the command line. In that case, it would refer to the previous
command by default.
You may like all history expansions with no events to
refer to the previous command line. In that case, turn on the option