From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29949 invoked by alias); 15 Dec 2014 18:27:06 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19547 Received: (qmail 8505 invoked from network); 15 Dec 2014 18:26:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=Kc1larcG c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=A92cGCtB03wA:10 a=_gHp24ddxIG86ml5DPIA:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <141215102652.ZM25198@torch.brasslantern.com> Date: Mon, 15 Dec 2014 10:26:52 -0800 In-reply-to: Comments: In reply to Rocky Bernstein "Re: An example of writing a custom history file?" (Dec 15, 12:05pm) References: <141214185332.ZM24112@torch.brasslantern.com> <141215003717.ZM24212@torch.brasslantern.com> <141215081440.ZM25053@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Subject: Re: An example of writing a custom history file? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Dec 15, 12:05pm, Rocky Bernstein wrote: } } Making the change suggested, adding 1000 doesn't change the behavior - no } file is written. Again, here is the entire 12-line program: } } #!/usr/bin/zsh } fc -ap /tmp/example_history 1000 } } local line } # Read lines and add them to history } while vared -h -p "hey: " line } do } [[ $line == 'quit' ]] && exit 0 } # The -s option below adds the line to the history } print -s $line } line='' } done This worked for me exactly as written; I got lines saved in the /tmp/example_history file. However, I was working with an interactive shell, which normally saves history at exit. If you are trying to run this as a stand-alone script, you probably don't want "exit 0" there. More likely you just want to "break" and let the loop finish. Also if running standalone, there's no "function scope" so I suspect that foils the usual action of "fc -a". Try it like this: fc -ap /tmp/example_history 1000 1000 local line # Read lines and add them to history while vared -h -p "hey: " line do [[ $line == 'quit' ]] && break # The -s option below adds the line to the history # The -R option avoids other "print" processing print -sR $line line='' done # Save/pop the pushed history fc -P You might also try adding setopt localoptions incappendhistory so that the lines are written to the file as soon as "print -s" adds them, rather than waiting for the "fc -P". } When the basic history mechanism isn't working, it doesn't help to pour } over a 138-line program that performs several functions in one program, } adds key bindings, beeps at the terminal, has color themes, and uses some } sort of "{ } aways { }" construct that probably is a Zsh extension and not } POSIX shell construct. You asked to be pointed at an example; I can't point to something that doesn't exist, so I pointed to something that does. However, if you're writing a zsh debugger, presumably you need to know about and potentially use zsh extensions?