How can I enter some kind of "private" zsh shell session where none of my commands will be recorded in the on-disk history?

I know there is an option for adding a space character before any/each command to avoid it being recorded in the history, however, I'm looking for a solution that is not requiring adding a space in front of each command.

1 Answer 1


Launch a new zsh shell and disable history within it.

Option 1

zsh # or just `$SHELL` if you're already running zsh
...secret commands...

The secret commands won't be stored in the history file.

Option 2

zsh # or just `$SHELL` if you're already running zsh
fc -p
...secret commands...

The fc -p will switch zsh to a in-memory history that will be discarded when you exit.

The downside: the previous history (commands entered before the private session started) will not be available.

  • Great answer. One small note. For me running echo $SHELL from zsh returns /bin/bash. I believe it points to login shell rather than current shell
    – RaZ0rr
    Apr 12 at 18:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .