From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id D8EA722347 for ; Wed, 5 Jun 2024 17:55:11 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1717602911; b=Uv57UEeRLJwfPI0cs82tdzMFtlQ+rHwOjvH9BJj2HsUhJyhSQPwENFFkh2I11Agp0P4ZZKJtIg ydJplNxJM2WZkK1Qu81VfuAS7ZBZEiIJ3NbLDmTHP7+R6ebjjUgYE+Sj3Uey3FaxnmEM2JF/BO 7dd8fEE5OvH+N3aHI3DBgvjrpbGn99YwJl5/CBVG63wRRk/wc9KxX1BXU8I0Wpg9wPdkbhbaYd FZv4WEr/28Rwj23tnwYDUIZ6NJiaESp7VcVhej9RhyyCj0ftCkjKWGbHP5fF2kYH1cp77mfcLC Udw5EpzNyftHs8WsBC/3yaTxSOahdk4gzv1yURExaiIS6Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f177.google.com) smtp.remote-ip=209.85.208.177; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1717602911; bh=9q4QrEM/DAyiZe1LgTkO6NxTOxcAkpa7toWCRP0aZao=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=cj0N8+eha/vNJLTpCVYTVbxcRsuN6MB17qwdUPm7WnR/KemEXEqMYJZkTBKAAuUn6MkosPuc9J SCgUtXOfvgAfba507qppFw8t4daSdKVdKDquww1rSl7CMPDhyKB0uXR1URDQ+xLMnbsVdLwjlq Yqfei9tuUwxaOoWxvi1Gd16xZZ2xTtXqVREnQk0cmBayy3MXboKLNX1FFWLeJ9eLDV/FfQ2ptx 86UicpFczgk6seKHq7givzd1O0hO3Kub4itzzEy6lWCnhUWSQpXBEE+yo6SyqqoZryWiQEXpbd PmV1VFsWCSmcT+91S41DwhoYSF1lzgOmnRSLG55x2yPRWQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=EsVw5dPgfxLqSwahD0gUw2+F+aATYMp6R5SJ3ca9p+E=; b=A8RHNzRnBW5xcPJdvIMTkmyxvx f2ALvjcHLJYXB61CmVHEV7X2wZc3ZToeeMAYjrk93RLMkmdsltPteWSkv5UpvPuKrk3Xjsbh4qFHo 8Mlz9NrZ5xS9LuQSY1kZwHDyOXczkydRyJWNZBhJX5Sz1eJHxoNdmVz0mSzXWDuaNIRWP/GYUX7+W CO9uJT7C3DjPkH+7D9UNFj8wyxf/8brTxY4clsZ+GEwequ+DzzAEYzf0QC2Bb1WFQDATfRRojGkFa /yLnTcpg1CfHDM4ZW7Gzen47wKpNUv94ZgEE5FvlKftdz8u1wYj41fkS5yisuqYB/S6IR/0GHUXmY hq4c4mRQ==; Received: by zero.zsh.org with local id 1sEsyl-0003QP-7l; Wed, 05 Jun 2024 15:55:11 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f177.google.com) smtp.remote-ip=209.85.208.177; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f177.google.com ([209.85.208.177]:47231) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1sEsxq-0002iX-4z; Wed, 05 Jun 2024 15:54:15 +0000 Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2eabd22d404so25918031fa.2 for ; Wed, 05 Jun 2024 08:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717602852; x=1718207652; darn=zsh.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=EsVw5dPgfxLqSwahD0gUw2+F+aATYMp6R5SJ3ca9p+E=; b=irlN71EJ4tybwJdNLfD1j4raUy+DJXIMgkcJVWeyhoaprTfs7dDFbO91ybPwjVm6OM 41M8u44FfnUkCvSFolx+xv9HudiD6eqrOt1TUIgJfdWTi7FwXu2Q/esG9pI9/PumtD8K orTVsyhRP0Z/RdE5sb6vzlBVJhvLTsAoYq7XFrZsVfhh4k68qTSR2mFbqI+ub2+AWtHu 01aWRmdREwb2gp8R9vfi/toKNoy4Jg/VOU6f41imQhB782+hfCdUsrGipmus+EH4KqPr K3UNLEd8iqn9g3sUiCmTwFcnzxJIcNMyxjkMFFvoHaMf/8O9iixYfEET3SZ7FOC6KemR RFYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717602852; x=1718207652; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EsVw5dPgfxLqSwahD0gUw2+F+aATYMp6R5SJ3ca9p+E=; b=OAfWuertE9CCzT+CoTVwYQj/Wu0/kZJnWM43ZJSakwhs4YDZ147CyseP5bj2qPzexd ETp1RflJFLRWAy85zmELG7ZfcDz7QlBspuxNaerbKH1Jx5lSrWZfza8BuGBQS7yX0Uia O+92Nraw1fiG8XDpf7LvXelyL0H9SrOWVebqqahPANU6p+gpCgUQ/Fd6R62K4ESsdK0S OW1+kVUv0KmEn1F9t9bnwYxZI6V1pU2FeVP8HhIljQYA9cg1frrCq3zDRVUccjcIySUV CJY4iYwMMjBmf9jjVa05Q9NSbOK/NLRTJFhEbFZWjgHeiAky/UOiX5MaF9GopS+VXjvf U6Bg== X-Gm-Message-State: AOJu0YyYfBgKt8srOBFApjG9aSezdU5NlKa/33RDlJ2vBW7eaqkpmXXb JmzmnlbOErZj7qiM12+8YfgoE7P9Y00nS3RIxpIfkuHgWctYClj3yWorajh8MHPcncl/9Z6ENCE qQD/klUXkyTgdCZylqIlvMGj+zDlzhB+x X-Google-Smtp-Source: AGHT+IHM397amKh5wuSx/hrzhn7gqQlhtiBw/XxfljwvIl+sBhJ2vfrK2QMh3mp1L8wAClDX0xpbKxYASfrdyHHiqVI= X-Received: by 2002:a05:651c:a0d:b0:2ea:90db:ffd2 with SMTP id 38308e7fff4ca-2eac798a88cmr22356171fa.4.1717602852291; Wed, 05 Jun 2024 08:54:12 -0700 (PDT) MIME-Version: 1.0 References: <32c690d4-fe7f-4d89-ac99-829fa64cca15@eastlink.ca> <81576af9-80b3-4bcd-b23b-c0d67cff1870@eastlink.ca> <2603f68c-1e38-44a5-80e6-0bc6d3bb4d27@app.fastmail.com> <19c7bc51-5f28-4307-a0f7-35d0e2105811@eastlink.ca> <3ebb8929-cc5b-4174-a6c7-6c394afb0111@app.fastmail.com> <7d3f9a1e-f3c2-459a-b549-0432e649036d@eastlink.ca> In-Reply-To: <7d3f9a1e-f3c2-459a-b549-0432e649036d@eastlink.ca> From: "Mark J. Reed" Date: Wed, 5 Jun 2024 11:53:59 -0400 Message-ID: Subject: Re: history puzzle To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="000000000000e04f03061a269363" X-Seq: 30009 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --000000000000e04f03061a269363 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jun 4, 2024 at 10:01=E2=80=AFPM Ray Andrews wrote: > > > On 2024-06-04 17:33, Lawrence Vel=C3=A1zquez 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 do= es > 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 --000000000000e04f03061a269363 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue,= Jun 4, 2024 at 10:01=E2=80=AFPM Ray Andrews <rayandrews@eastlink.ca> wrote:
=
I was re= ading 'info zsh history'
That shows the "History Expansion" section of the manu=
al, which
does not mention the "history" builtin at all.

Ok, at least that's clear.=C2=A0 I should be using 'info zshbui= ltins'.=C2=A0 'History Expansion' ... I'm taking that to be what the hist= ory command does so ... actually now that I look closely, it's obviousl= y the wrong place.=C2=A0 And 'run-help history' goes somewhere el= se entirely. =C2=A0=C2=A0

The term "history expansion" refers to the exp= ansion of references into the command history. Those start with=C2=A0!,= =C2=A0for example:

zsh% vi path/to/some/file
zsh% gcc !$ # compile the file I just edi= ted

In general, the=C2= =A0!=C2=A0is followed by a selector that determines which item from = the history you want to copy from. This can be an item number (which matche= s the one shown by=C2=A0history/fc -l), another=C2=A0!=C2= =A0(which means the most recent command), or a prefix string (which ref= ers to the most recent command starting with that prefix, e.g.=C2=A0!ls<= /b>=C2=A0to refer to the most recent=C2=A0ls=C2=A0command). The sele= ctor can be followed by modifiers to restrict the expansion to just part of= the command:=C2=A0:0=C2=A0for the command name,=C2=A0:*=C2= =A0for the arguments without the command name,=C2=A0:$=C2=A0for just= the last argument, etc. The=C2=A0!!:$=C2=A0expression (last word of= the last command) is so common that it got its own shortcut, the !$= =C2=A0I used above.

History e= xpansion is purely an interactive command-line feature; it doesn't work= in scripts. If you need to access the history programmatically, use the=C2= =A0fc=C2=A0command (or=C2=A0history, which is equivalent to= =C2=A0fc -l).=C2=A0
Anyway, that's= what you were reading about. :)
--
Mark J. Reed <markjreed@gmail.com>
--000000000000e04f03061a269363--