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 14397 invoked from network); 21 May 2021 23:55:39 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 May 2021 23:55:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1621641339; b=gJ8Qfj61CJflRqg3K8dnffgvrI6kdVhz6kReP4alcF8qi3gVmwCZanN3Hst0Keu90gD3PjI57X ctVjO/cXcscOtmqA3MnDHcMmlS4nC1a88UcvCD0EmiVPleQhfDv5f+mJwyWIUflrMdX12T/Oce RPZU+Y4Hm72GB9yuFmDT/esISjJjAHOkC7N6RQVhhsKRz5Z8cYhIHg1GbZH7NJqgZQhQAFhtZ8 qwNcN32N0jMDdQIKm5QjA/gl1ywnIAJpqkwlzq120CE8aKBXXBwB0t6WSRkP2H0PaxJVFFLYDp 3B7EVucLouWjzjwPCIv2v4CwmKp25LpoAsapS/5oJ95jBA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f174.google.com) smtp.remote-ip=209.85.167.174; 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-20200801; t=1621641339; bh=R8BGhJzwev2RF1BABsN6qpqRNIsiGQty8FpNs2uTku4=; 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=Wg4qYn+GbKwk1OFUdnJMXKcxOJZT8D/aM9CuGdhMeTdrZ3Q+EWDX9sKQ2e6UcKsslbx7h/Sqw3 V4KsYasl1Ufqmi97J6iaa20mL+Tfsx56VGGWap4vd+z75V6RVCvoLC2+IH6Qp5u8QA7IM7MPbw L0doL86lUwNT1HpniZM6Zp5MY0ChlJE7qL9FeauAv6/0eexvSL8DAIFShkRib/gbAohbaVs6Q4 X097i+OW5WaWelit3FFEtc67qMK5VvNfBmOmWm5ZAl+UHU6h1wUQaM+rqXjg6OVPxpqm8K1sWJ AkjiQswV7T2VlNHB1Iw49qcatscN9UXsr58DnZOOuM2BdA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; 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=2ADyCfEuX1HbvgKMWKoKoStaTL3Av2FdSNc0S5ElOpM=; b=f3yHtTMwA92aCmpp9Q59dJYQO1 f837rclFNp9AY4Ez89Fvq1onCIQWiU0ICPKLxabfJl2xmu64OjY6foAv3UDhpEbj0Or5lQ014MAKx zc6Bbcrl0ma2wdBGzq47C6rQgM8YuAnvofdlHjrcFAeJYFjDQj40RoHw7OhkzJp50lY7y6ib3GI/F O5Oq3W3v54yFqYbYqTMF+Tm+J2XHZtXOkdiYIUONDvN6KgEgEevAiol6tCTM8HHrCQjcqjhZ53XHx NqRbnz5iXej8q1dfvrSXo24k9yyfrrWC+M8Bc41oIhxC2qB3DL3FO8zV+yAEB6fWwVVm6G4dg5Im0 eppTStbQ==; Received: from authenticated user by zero.zsh.org with local id 1lkEzT-0002Pv-94; Fri, 21 May 2021 23:55:39 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f174.google.com) smtp.remote-ip=209.85.167.174; 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-oi1-f174.google.com ([209.85.167.174]:45761) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lkEzE-00026H-08; Fri, 21 May 2021 23:55:25 +0000 Received: by mail-oi1-f174.google.com with SMTP id w127so17425155oig.12 for ; Fri, 21 May 2021 16:55:23 -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=2ADyCfEuX1HbvgKMWKoKoStaTL3Av2FdSNc0S5ElOpM=; b=tPmXfdYqhsoveSvgHmkgAC/DpcVmpaEuFwROqWimQ3Jn9GAUAi8kADUolcXWpQPQKl wYYIIDdiyyNXhYhKCZJOcS4vSfir8AcnFNcCsSkob/yDbwVoLjoyr3/4ospnZI8nzz5H Ja2vO4daGYELCkUCQg4PwTtGXVCjr1eIF65ISei/maoCKM7y+9Yj1BNlxVNpgjaGsHFV uEHjtDhQ3yw82CgynLh3cE/Ok1QaQTxJbx9vilHx9NLFljhU/+LGjZqJiDwLJ9xEgv6l omHyN6dOkczilPaoqT5nCaeMOFstz1C3mo0qEePHQdMSvQPA2zBm1nRA9HSjkdNOY990 qNDA== 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=2ADyCfEuX1HbvgKMWKoKoStaTL3Av2FdSNc0S5ElOpM=; b=fPL4HERqa6TTScFrDg7YQ7o9uYPJ0Dxntz+LHbrPmf1pjkj5y5fBQLLx5WVlBBsh60 fcgy16O6NE4yV3Sl50pC19+UvrnSaU0LjkTHDKCuVhTJQrmO9xP8J4VQ3th7ZMe4x1Py dGSLiD/3okSL50E1Dwa1zJr6K4VB6aN5w715TM6yxmFQgFxKezdhyXK/mEMlVemxCe/1 tNMW8jdAx711fVcOAepnBBE3FIDoWm18zEDJMun6ovVq6ewAAfANR74w2/Xf1du3yJY4 FXBtElzxiMUwqtDQVG5+77bEBft/baztR9sNM16eoH5quyMDqyMx2vimSQ26D8BSPbX4 Cgtw== X-Gm-Message-State: AOAM533EDFtPtEI2O6+JL51WcQkm3tqGdczUmzRzuPfShp2M/ru3/RDq 7E6P3vd+0eapP6Q7Irga8V4Pu9MYoH74f35IBH1a+w== X-Google-Smtp-Source: ABdhPJwQXTd90GZanhfBgSgWqJtr63cwMKAkuLQzopqiyYVCY8NPeM0/xN4v+rAkeY1XdewQVg2jJ8Hh4mD6kqIkWI0= X-Received: by 2002:a05:6808:64e:: with SMTP id z14mr3921679oih.173.1621641322523; Fri, 21 May 2021 16:55:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Fri, 21 May 2021 16:55:11 -0700 Message-ID: Subject: Re: %! prompt code shows incorrect number To: Mikael Magnusson Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 48898 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Fri, May 21, 2021 at 11:58 AM Mikael Magnusson wrote: > > I've gone with the below hack for now. What I want to be able to do is > copy the history number from the prompt and paste it back into the > terminal I take it this means the history number from some previous prompt. So the code in your patch starts at the history number requested, and if that points to a foreign entry, scans forward until it finds a local one. > I don't think there's any existing way to check if a history entry is > external other than parsing the * out of fc -l output? It shouldn't need THAT much parsing. Approximately (in bracketed-paste-magic idiom): historynum=${${(z)"$(fc -lIL $PASTED -1)"}[1]} # dash ell eye L for those with sans-serif fonts PASTED=$history[historynum] I don't have shared history to test with, but that should work, with the caveat that if you paste a number that is less than $((HISTCMD-HISTSIZE)) you'll just get the oldest local history entry (which I think is the same with your patch). Of course if you have thousands of lines of history and paste a really long-ago number, that's going to use a lot of memory.