I'm looking for the zsh equivalent of the bash command
history -c, in other words, clear the history for the current session. In zsh
history -c returns 1 with an error message
history: bad option: -c.
Just to clarify, I'm not looking for a way to delete the contents of
$HISTFILE, I just want a command to reset the history to the same state it was in when I opened the terminal. Deleting the contents of
$HISTFILE does the opposite of what I want: it deletes the history I want to preserve and preserves the history I want to delete (since current session's history would get appended to it, regardless if its contents was previously erased).
There is a workaround I use for now, but it's obviously less than ideal: in the current session I set
HISTFILE=/dev/null and just close and reopen the terminal. This causes the history of the closed session not be appended to
$HISTFILE. However, I'd really like something like
history -c from bash, which is much more elegant than having to close and restart the terminal.