From mboxrd@z Thu Jan 1 00:00:00 1970 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, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18538 invoked from network); 7 Sep 2021 21:31:22 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 7 Sep 2021 21:31:22 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1631050282; b=Q7OAG5gfiRZpoBS6gBBzziq/9IzVF2eJ4fA6RW6hmCW6PXI5E3PHxY45RcdRiyvIyVKGGriRiO IvY14h8WJSoobvf4sk5u4/nRe8zRPVIPygA0hYTB38KJzvUslBeCUEMa9bGA3cTtdklZattx5g cHlMt0jpUlm3y1j2bgwDcRQU8OqxxcHIzmmmVzZd2mk6sx9LYopEkHPJOzCJ8TRc8VXp01gNtR 8SNv0dMfasg+BTYsDdslmuDGCOcj5IbXKoc8QOAczEu/OFjt6WRVcSTa+/Fdv3m/SnosPyw7Gg U8ARo1GVm9kFWl93cUfW+Jr9vCFfCZad9F0w/2wxzmQOFw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f176.google.com) smtp.remote-ip=209.85.219.176; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1631050282; bh=ITkH7LYjBKDoZSaKyPcWhkCT1QtYucM2UPHJGdFG/bE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=pt5MZGGzTEvc0DB/3ti/toITNtVxtaKtmA8CTJgBsZ2P8sdfatuNxE1KDVe7GVloYBfKljYx0U v1tUWWQo9KZ17w7axf1cC2ffF4SyWxXDqfr2d1yJu4r6ZaKk6HlTRergkXDdIu6wh/gHwj/a18 7bz/5/ELoIRO9/HVexCz4Xz5HeRxEpZeWTLM8UNI6kJ8mQe7tXOndhliG0F3UIJr7LD9hG1sc0 mIpOQI9QEAq5Dr74MbBVaySGR9+U9HZjhzz2tqJhLVdXpjk6WUUUKyqhm+mlopNNiLypZO6Kv+ k2SJhoTIGOqAoOC6d5scxsUgON4KCtZ4rFuLyYj3nJsXWw==; 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:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Gwt85CciwYg5pfYIL+3wSAG2K4I2M/y7+sIpw1dWItk=; b=J2E4bcbTsWGvBC+MVESJeRRu96 CMNpxw5Sjh8l22VppOkazslKT9Q5w2yewWIzfP5zTyHCP9XTfPZ7SfLuLDpsPqh5KTOBi9zHzEZC9 LnEko6Y00CYHvE9bM4trKWpc1aBAVYkc5G5asxOvsfXy/HBBmVT/47HkgL1OrHEeEVWu/eUM0oUGc 2sCoLSvZudWB9AlVE+AZixGZGnSNTBeo6Arg4Bx91X7Mmhr1UQhLPbGaTMTG28GPJWSmqs+wUta7j 9ctyG17Bf4sWXN1Iu4BXJl72NvhGIRT+enp2vSCd3ZBXQg87LzaL8sGgyvQF6s4HWcN3GIYZYEVix ousiZzpA==; Received: from authenticated user by zero.zsh.org with local id 1mNiga-00070v-Pk; Tue, 07 Sep 2021 21:31:20 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f176.google.com) smtp.remote-ip=209.85.219.176; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-yb1-f176.google.com ([209.85.219.176]:43906) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mNifh-0006IM-Dj; Tue, 07 Sep 2021 21:30:25 +0000 Received: by mail-yb1-f176.google.com with SMTP id c6so1281175ybm.10 for ; Tue, 07 Sep 2021 14:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Gwt85CciwYg5pfYIL+3wSAG2K4I2M/y7+sIpw1dWItk=; b=GLtSdvdPPJu27YA9dHdADBqtyF6SiBW2AZFZWbymkK4GXw1tylGTAaQxEyCEJMTG3J Mc7pPnYWJTgSo/yBzY2W/L28hgrgmdeMlgCDaMdwU/Dpm/RS1n4wS0GHe5RYf6QykqCO VtlGQSn1o1alPLqSAiSeWMN0zJzxsKQVXp1pqlG/40ySzQgt/y7Ump3l3ha55nGQNqcK GW0qI5ehfqV5dJmARAF3253QQEEmxl8vYALMRM/MRcUYPPRprct+uixdy+lst1/U5sdQ RXU+zVB7wwOR1+2xXPz6BkX5dgEPDtku101LqsZGHqXc+awiq/2r/6agYiyektmvgfjJ TFyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Gwt85CciwYg5pfYIL+3wSAG2K4I2M/y7+sIpw1dWItk=; b=dBWVeOrNXu0Hxmvu22K4KO97ChqXGVsnRUh5pZbvLVLZPESSuhciT5TKOdcdHl1QA8 y3WlheobrGzPk1eXm0nxf0lwHZM+kDHZYbKMQO3E4BS72QuCi2qREqJ1y376hbrXB/wW bAAb1b3YYFoaxDGuACREie8ZaMtPBAa0b7fIpiWF4I30AAMetYqO2CdXMUrUkw0Y69ML 89xHGS1Rp0nS644tmWnwIza/nZhulEooOJuDsA8vawkC2btnvudCN9mCr16pL2W1MTpd E7mVsPyJi1PX92KWUsCs0vXJTHhoD/cJos7/YUwGm7zCLT4UYTGeB0nUSkMsa60T6Okp cDRg== X-Gm-Message-State: AOAM531mKgdxmvvYNDYdhhsCLnFu64uMlxXdLIIz3YknAejY3Viek4nJ gJ7HcxkQb0AabApYcve4rn0pnOlyCQDTDYffbDWq3a/7Sp0= X-Google-Smtp-Source: ABdhPJy9xoBt9DMiUW4WZHi1ym0uX8KrGcUvTko57JYcvS2aApfsWFG5CVqRcN10gCf+yU5o0iVyYsoHni1k2ZUVjpo= X-Received: by 2002:a25:21c5:: with SMTP id h188mr571713ybh.23.1631050224296; Tue, 07 Sep 2021 14:30:24 -0700 (PDT) MIME-Version: 1.0 References: <20210907105355.atgr45xbrjgbjtwr@trustfood.org> In-Reply-To: <20210907105355.atgr45xbrjgbjtwr@trustfood.org> From: Bart Schaefer Date: Tue, 7 Sep 2021 14:30:13 -0700 Message-ID: Subject: Re: Reverse history search and match for a specific token To: Eric Smith Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 27100 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: On Tue, Sep 7, 2021 at 3:54 AM Eric Smith wrote: > > I use event history matching a fair amount and can subscript the command to return a specific token like this. > $ !?foo?:% > for the token containing foo > > How would I match for the token containing `bar`? If I understand the question, you want the token containing bar from the most recent command that contains foo, even if some other intervening command also contains bar? There's no single expansion that will do this. What you would need is: !?foo?:p !?bar?:% The :p step duplicates the most recent entry that contains foo, without executing it, thus making it also the most recent that contains bar. You can then use :% to extract the bar token. To do it in one step you'd need ${(M)${(z)history[(r)*foo*]}:#*bar*} but that's four and a half times as much typing.