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.
setopt SHARE_HISTORYor are you usingsetopt INC_APPEND_HISTORY(both of these writes commands to the history as they are entered)?setopt APPEND_HISTORY. I'm quite happy with how that works, it appends the current session's history to the$HISTFILEwhenever the terminal is closed. But sometimes I want to clear the history during the session (when I write something stupid), but preserve what is in$HISTFILEhistory -p?