From: "Mark J. Reed" <markjreed@gmail.com>
To: zsh-users@zsh.org
Subject: Re: history puzzle
Date: Wed, 5 Jun 2024 11:53:59 -0400 [thread overview]
Message-ID: <CAA=-s3yrBmy4LZcA3awCJarLanVoSBCXwnzErkuDoMBMe_NODg@mail.gmail.com> (raw)
In-Reply-To: <7d3f9a1e-f3c2-459a-b549-0432e649036d@eastlink.ca>
[-- Attachment #1: Type: text/plain, Size: 1833 bytes --]
On Tue, Jun 4, 2024 at 10:01 PM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
>
> On 2024-06-04 17:33, Lawrence Velázquez wrote:
>
> I was reading 'info zsh history'
>
> That shows the "History Expansion" section of the manual, which
> does not mention the "history" builtin at all.
>
>
> Ok, at least that's clear. I should be using 'info zshbuiltins'.
> 'History Expansion' ... I'm taking that to be what the history command does
> so ... actually now that I look closely, it's obviously the wrong place.
> And 'run-help history' goes somewhere else entirely.
>
The term "history expansion" refers to the expansion of references into the
command history. Those start with *!, *for example:
*zsh% vi path/to/some/file*
*zsh% gcc !$ # compile the file I just edited*
In general, the *!* is followed by a selector that determines which item
from the history you want to copy from. This can be an item number (which
matches the one shown by *history*/*fc -l*), another *! *(which means the
most recent command), or a prefix string (which refers to the most recent
command starting with that prefix, e.g. *!ls* to refer to the most recent
*ls* command). The selector can be followed by modifiers to restrict the
expansion to just part of the command: *:0 *for the command name, *:** for
the arguments without the command name, *:$* for just the last argument,
etc. The *!!:$* expression (last word of the last command) is so common
that it got its own shortcut, the *!$* I used above.
History expansion is purely an interactive command-line feature; it doesn't
work in scripts. If you need to access the history programmatically, use
the *fc* command (or *history*, which is equivalent to *fc -l*).
Anyway, that's what you were reading about. :)
--
Mark J. Reed <markjreed@gmail.com>
[-- Attachment #2: Type: text/html, Size: 3256 bytes --]
next prev parent reply other threads:[~2024-06-05 15:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-04 18:00 Ray Andrews
2024-06-04 18:12 ` Mark J. Reed
2024-06-04 19:28 ` Lawrence Velázquez
2024-06-04 19:52 ` Ray Andrews
2024-06-04 20:18 ` Lawrence Velázquez
2024-06-04 19:49 ` Ray Andrews
2024-06-04 20:19 ` Lawrence Velázquez
2024-06-04 20:37 ` Mark J. Reed
2024-06-04 23:51 ` Ray Andrews
2024-06-04 23:48 ` Ray Andrews
2024-06-05 0:33 ` Lawrence Velázquez
2024-06-05 2:00 ` Ray Andrews
2024-06-05 15:53 ` Mark J. Reed [this message]
2024-06-05 16:13 ` Ray Andrews
2024-06-04 18:54 ` Kannan Varadhan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAA=-s3yrBmy4LZcA3awCJarLanVoSBCXwnzErkuDoMBMe_NODg@mail.gmail.com' \
--to=markjreed@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).