Cleverly skipping statements from being saved to history in your shell.

I recently had to execute a command that I did not want the shell to save in its history.


After a little searching, I finally understood what this little variable HISTCONTROL does. Definitely seen it around, never bothered with it; one of those things.

As long as it is set to either ignoreboth or ignorespace, anything starting with a space will not be saved to history.

 echo "Hello world!"

The command will still execute as normal, but that extra space makes a difference. Continue reading with an authoritative article on from 2009.


Thanks to rzg for pointing out the zsh-equivalent: HIST_IGNORE_SPACE.


Join the discussion on Mastodon, Twitter, or write me an email.