Privacy By Default in Zsh

Zsh, the Z shell, can log every keystroke you make into history files. For most setups, that history is stored by default in ~/.zsh_history. Every command, every argument, every path. On shared machines or in cloud dev environments, this is a risk. Credentials in cleartext. Access keys exposed. Sensitive file names preserved forever.

Privacy By Default flips that default. Instead of writing your commands to disk, it discards them unless you explicitly enable logging. No history file, no persistent shell memory. The core change comes from setting:

unsetopt HISTFILE
unsetopt HIST_SAVE_BY_COPY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE

With unsetopt HISTFILE, Zsh forgets everything you type. This stops the shell from saving commands in a local history file. Combining HIST_IGNORE_DUPS and HIST_IGNORE_SPACE can further reduce ephemeral memory use, if you choose to keep short-term session history.

For engineers working on production systems or handling direct access to databases, Privacy By Default in Zsh reduces risk surface. It means one less vector for leaked secrets. It works in containerized builds where ephemeral shells should remain clean after exit. It works over SSH without leaving traces in your home directory.

Implementing this in .zshrc makes the behavior automatic on every new shell session. No additional tools, no runtime cost. Just add the lines, save, and restart your shell. Combine this with restricted permissions on your user directory, and you lock away one common leak channel entirely.

For teams adopting secure-by-design practices, making Privacy By Default the baseline in Zsh is a low-cost, high-impact move. Test the configuration in staging, then roll out across development and production shells.

See how Privacy By Default can be integrated into secure, ephemeral environments with hoop.dev. Run a shell with zero history and complete isolation—live—in minutes.