41

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'

0

1 Answer 1

47

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.

3
  • 10
    This was "set -k" on my machine.
    – user732
    Commented Mar 12, 2012 at 11:57
  • 2
    Thanks, "set -k" and "setopt interactivecomments" both work.
    – Not Now
    Commented Mar 12, 2012 at 17:09
  • Updated link to source zsh.sourceforge.net/Doc/Release/Options.html
    – OrigamiEye
    Commented Mar 26, 2020 at 7:25

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