on
CC-BY-NC-SA-4.0 Apache-2.0
1 mins
π€ This post includes some LLM-derived content π€
Disabling zsh history for a given shell session
This post's featured URL for sharing metadata is https://www.jvt.me/img/profile.jpg.
This last week I've been doing a few bits of working with secrets - some of which I've needed to store in local environment variables, or pass as arguments to commands, and I've been going in and scrubbing my ~/.zsh_history
after the fact, to make sure the secrets don't retain in my history, on disk.
However, I wondered if there was a way to temporarily disable history storing. I started by asking GitHub Copilot, and GPT-4.1 responded with running the following:
unset HISTFILE
export HISTSIZE=0
export SAVEHIST=0
This was actually a valid thing to do stops that zsh
session from retaining any history, until you start a new shell, where it will be reset.
After running this, i.e. ~/.zsh_history
won't contain any of the commands, other than noting that you disabled history.