Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 22 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
This wasn't working for me, until I read the whole text and realized it's awesomer than bash!! – 0fnt Aug 19 '14 at 9:51
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.