Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: An example of writing a custom history file?

On Mon, 15 Dec 2014 12:05:30 -0500
Rocky Bernstein <rockyb@xxxxxxxxxxxxx> 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

I'm not entirely following everything you're attempting to do, but the
feature you're using is for temporarily switching a history file during
a shell session.  So if you're running this as a script (rather than a
shell function), as the #! and the word "program" would imply, (i)
you're not really trying out that aspect of the feature --- though
there's no reason the basic feature shouldn't work (ii) you don't get
the "autopop" behaviour at the end of function scope that the -a
additional option to fc -p implies.

Try using "fc -P" at the end to pop by hand, as if this actually were a
function (but with the save line number argument suggested by Bart).


Messages sorted by: Reverse Date, Date, Thread, Author