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

Re: zshaddhistory confusion



On Sep 26, 11:01pm, Benjamin R. Haskell wrote:
}
} The following doesn't seem to work, though I'd have thought it would 
} based on the documentation...
} 
} zshaddhistory () {
}     fc -p ~/.zsh_history_detail
}     print -sr -- "${1%%$'\n'} ### ${PWD} $(date '+%Y-%m-%d %R')"
}     fc -P
} }

"Doesn't work" how?  What does it [not] do that you were expecting?

     A hook function may call `fc -p ...' to switch the history context
     so that the history is saved in a different file from the that in
     the global HISTFILE parameter.  This is handled specially: the
     history context is automatically restored after the processing of
     the history line is finished.

What "handled specially" means here is that pushing the history stack
when you are inside the history hook automatically disables writing
to the normal history file, regardless of whether you "return 1" or
call "fc -P" or anything else.  That should probably be made more
explicit in the doc, the only thing it's describing is the implicit
"fc -pa".



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