From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4376 invoked from network); 1 Mar 2008 03:23:02 -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; 1 Mar 2008 03:23:02 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 64131 invoked from network); 1 Mar 2008 03:22:47 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 Mar 2008 03:22:47 -0000 Received: (qmail 18060 invoked by alias); 1 Mar 2008 03:22:38 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12663 Received: (qmail 18048 invoked from network); 1 Mar 2008 03:22:38 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 1 Mar 2008 03:22:38 -0000 Received: from vms173001pub.verizon.net (vms173001pub.verizon.net [206.46.173.1]) by bifrost.dotsrc.org (Postfix) with ESMTP id 9365E8026E0B for ; Sat, 1 Mar 2008 04:22:34 +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 <0JX100FI57HORGMA@vms173001.mailsrvcs.net> for zsh-users@sunsite.dk; Fri, 29 Feb 2008 21:10: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 m213MJag018083 for ; Fri, 29 Feb 2008 19:22:19 -0800 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id m213MIwD018082 for zsh-users@sunsite.dk; Fri, 29 Feb 2008 19:22:18 -0800 Date: Fri, 29 Feb 2008 19:22:18 -0800 From: Bart Schaefer Subject: Re: Editing history stack during runtime? In-reply-to: <2d460de70802291142u4bdf7c94qa330ff9dad1324f0@mail.gmail.com> To: "zsh users" Message-id: <080229192218.ZM18081@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> Comments: In reply to "Richard Hartmann" "Re: Editing history stack during runtime?" (Feb 29, 8:42pm) X-Virus-Scanned: ClamAV 0.91.2/6054/Sat Mar 1 03:21:45 2008 on bifrost X-Virus-Status: Clean On Feb 29, 8:42pm, Richard Hartmann wrote: } } I want to take the session history, i.e. what was typed since last login, } and edit that. Then, I want whatever I save to replace the session } history. I have a vague recollection of something like this having been posted before, but not since we added "always" blocks and similar fun, so: edit_hist () { emulate -LR zsh unsetopt append_history inc_append_history share_history # You may want these in this case even if not otherwise: # setopt hist_expire_dups_first hist_ignore_all_dups # The following gibberish creates a unique tempfile # and makes sure that we'll write the whole history local SAVEHIST=$HISTSIZE HISTFILE=${:-=(:)}$$ # Make sure we write a new file and rename to the tempfile setopt no_hist_save_by_copy # Finally, the actual useful work fc -W { if ${VISUAL:-${EDITOR:-vi}} $HISTFILE then # Truncate internal history to discard deleted lines HISTSIZE=0 HISTSIZE=$SAVEHIST fc -R fi } always { rm -f $HISTFILE } }