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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.