Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Bash I know putting a space before a command prevents it from being kept in the history, what is the equivalent for the zshell?

share|improve this question
cross-linking to (slightly more involved) bash answer:… – Michael Shigorin Oct 26 '15 at 10:53
up vote 26 down vote accepted

Use the HIST_IGNORE_SPACE option.


man zshoptions


Remove command lines from the history list when the first character on the line is a space, or when one of the expanded aliases contains a leading space. Note that the command lingers in the internal history until the next command is entered before it vanishes, allowing you to briefly reuse or edit the line. If you want to make it vanish right away without entering another command, type a space and press return.

share|improve this answer
great answer! thanks – bneil Nov 1 '11 at 20:02
I wish I could do this for all-the-commands-typed-in-a-terminal-window-since-open on OSX. For when you realize that you've been barking up the wrong tree. – Dan Rosenstark Nov 1 '11 at 22:57
And then, for the commands I wanted to prevent, I used aliases and prefixed a space: alias jrnl=" jrnl" – Sagar Jauhari Sep 23 '14 at 21:26
@Yar kill -9 that shell (if it doesn't do line-per-line history file writes) – Michael Shigorin Oct 26 '15 at 10:47
@MichaelShigorin Thanks! kill -9 $$ is indeed fantastic to avoid all the commands issued in current terminal session to be stored in the history. – Jeffrey Lebowski Mar 14 at 17:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .