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'


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.

  • 8
    This was "set -k" on my machine. – Bruce Ediger Mar 12 '12 at 11:57
  • 2
    Thanks, "set -k" and "setopt interactivecomments" both work. – Not Now Mar 12 '12 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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