Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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, if I type a command beginning with a '#', bash ignores it as a comment.

Ie, the following is ignored at the bash prompt:

> # Hi there!

Whereas in zsh:

> # Hi there !
zsh: bad pattern: #

How can I ask zsh to do the same?

This is incredibly useful to "store" commands that you want to run later, or to chat when using a shared tmux/screen session.

I am using 'oh my zsh'

share|improve this question
up vote 27 down vote accepted

Check if the INTERACTIVE_COMMENTS option is set.

According to this page, "[...] in interactive shells with the INTERACTIVE_COMMENTS option set, [...] # causes that word and all the following characters up to a newline to be ignored."

According to the comments were added later, set -k does exactly the same thing.

share|improve this answer
This was "set -k" on my machine. – Bruce Ediger Mar 12 '12 at 11:57
Thanks, "set -k" and "setopt interactivecomments" both work. – Not Now Mar 12 '12 at 17:09

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.