From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23236 invoked from network); 3 Mar 2008 16:51:17 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 3 Mar 2008 16:51:17 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 17578 invoked from network); 3 Mar 2008 16:50:57 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Mar 2008 16:50:57 -0000 Received: (qmail 136 invoked by alias); 3 Mar 2008 16:50:47 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12675 Received: (qmail 119 invoked from network); 3 Mar 2008 16:50:46 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 3 Mar 2008 16:50:46 -0000 Received: from vms173001pub.verizon.net (vms173001pub.verizon.net [206.46.173.1]) by bifrost.dotsrc.org (Postfix) with ESMTP id 2B1228028C53 for ; Mon, 3 Mar 2008 17:50:40 +0100 (CET) Received: from torch.brasslantern.com ([71.121.18.67]) by vms173001.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JX500AZQXAZ9330@vms173001.mailsrvcs.net> for zsh-users@sunsite.dk; Mon, 03 Mar 2008 10:18:37 -0600 (CST) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id m23GUGbm013913 for ; Mon, 03 Mar 2008 08:30:17 -0800 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id m23GUGmI013912 for zsh-users@sunsite.dk; Mon, 03 Mar 2008 08:30:16 -0800 Date: Mon, 03 Mar 2008 08:30:16 -0800 From: Bart Schaefer Subject: Re: Editing history stack during runtime? In-reply-to: <2d460de70803030425t4233caa9l57519aac0796d82a@mail.gmail.com> To: "zsh users" Message-id: <080303083016.ZM13911@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <2d460de70802281709n1847611cp6cb9a5273e212bae@mail.gmail.com> <080229084310.ZM17549@torch.brasslantern.com> <2d460de70802291142u4bdf7c94qa330ff9dad1324f0@mail.gmail.com> <080229192218.ZM18081@torch.brasslantern.com> <2d460de70803010238l5f221208q1bd0a090c9eca3a9@mail.gmail.com> <080301045937.ZM19496@torch.brasslantern.com> <2d460de70803030425t4233caa9l57519aac0796d82a@mail.gmail.com> Comments: In reply to "Richard Hartmann" "Re: Editing history stack during runtime?" (Mar 3, 1:25pm) X-Virus-Scanned: ClamAV 0.91.2/6094/Mon Mar 3 17:15:09 2008 on bifrost X-Virus-Status: Clean On Mar 3, 1:25pm, Richard Hartmann wrote: } } On Sat, Mar 1, 2008 at 1:59 PM, Bart Schaefer wrote: } > "The history accumulated since I logged in" *includes* the history } > read from the history file at shell startup. } } Hmm, now that I think about it, this _does_ make sense. Matter of fact, } nothing else would. I will probably try and hack something together that } uses a custom variable to store invocation time of the shell Hmm. Actually you can get away with discarding all history entries with history number <= than the original value of SAVEHIST (from *before* the assignment SAVEHIST=$HISTSIZE in the edit_history function). Assuming that you haven't changed SAVEHIST since the last time the history file was written, of course -- if you change SAVEHIST a lot you'll have to do more work to get the startup-time maximum history number. It's not particularly easy to discard those entries, though. Probably the best way is to put the "fc -W" in a subshell and truncate the history there, like so: ( # Needs recent-enough zsh to have HISTCMD if ((HISTCMD > histcmd_at_startup)) then HISTSIZE=$((HISTCMD - histcmd_at_startup)) fi fc -W )