6

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.

Totor
  • 19,302
  • 17
  • 75
  • 102

1 Answers1

10

Launch a new zsh shell and disable history within it.

Option 1

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

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...
exit

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.

Totor
  • 19,302
  • 17
  • 75
  • 102