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

Execute a command *after* reading $HISTFILE



My turn to ask a question.

When zsh starts up, reading the history file is the very last thing that it
does before entering the main interaction loop.

When zsh exits normally, it first writes the history, then reads .zlogout,
and finally runs the traps.

I have a situation where I'd like to read a different history file at
startup than is written-to at exit.  I can't simply call `fc -R' from one
of the startup files, because zsh will still read $HISTFILE and then I'll
have loaded both histories (and part of the one that I really wanted may
be lost if $HISTSIZE is reached).

It would almost work to call `fc -A' from .zlogout, but that gets into all
sorts of weird issues with incremental history.  What I really want is to
change $HISTFILE after zsh reads it.

Can anyone think of anything better than the following?

HISTFILE=~/.zhistory.$private
eval "function precmd() {
  HISTFILE=~.zhistory.shared
  function $(functions precmd)
}"

The problem with this, of course, is that if it's in .zlogin it doesn't
get installed in all interactive shells, but if it's in .zshrc then I have
to be careful not to change precmd again in .zlogin.

Suggestions?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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