Should interactive comments be defaulted to on for ZSH?

Since zsh is the default for a standard Manjaro (Gnome) user, this seems like a configuration flaw. But maybe this is only me.

Since the dawn of time (or the horrid user experience of the commercial *NIXs), I have used hash/# to comment out commands. This is handy to type out a command, then press ^A/# to comment the whole command out, hit enter and come back to it.

I’ve never known Bourne, Bash, or any other shell to act any other way. I only learned about the INTERACTIVE_COMMENTS option after Manjaro. I see OSX users that also use zsh with the same option disabled.

Of course I can easily change this for myself. But let’s not be like Apple! We need our hash!

Ouch … if I read you right the default is that

echo stuff # comment

is not understood as a comment, and instead you get something like

zsh: bad pattern: #

?

By default, the zsh shell enables the interactive_comments shell option in scripts (non-interactive shells in general), but not when running an interactive session.

As its only the interactive shell … I guess it falls under users choice.

Also worth noting is that its used by zsh normally as a ‘histchar’

Yeah.

It’s only new installs that I notice it, but I will never forget get one time I typed a long command with lots of piping and redirection, and it did not act like a comment for the whole line.

Whoops, this was edited in after my reply. Yes, in the topic title I say that it’s default am wondering about. I do change it. It’s just every new install, I think to myself… Why?

Commenting out commands in the interactive shell has been the only way I’ve used any shell. I’m curious why is it defaulted off, unlike everything else?

I usually remember to set that option, but there was that one time…

Edit: I also missed:

Also worth noting is that its used by zsh normally as a ‘histchar’

Well that’s unfortunate… Why would they use the comment character?

Dunno, according to the guide it be like this:

So its still used for comments … just introducing them yourself while using history?

Its also related to this other option

Of course you can always jump back over to bash if thats more comfortable … its what I do.

sudo pacman -Syu bash bash-completion
1 Like

My reply got lost a few days ago, in that incident.

I just wanted to understand the reasoning of the default configuration of zsh. In the first reply, you edited in:

So that one word made sense on the reasoning, histchar was the part I was missing.

echo $histchars                                                                                                           127 ✘
!^#

There’s a few ways of changing this. (Of course going back to Bash would!) I was just using the setopt interactivecomments option. I just couldn’t understand why this wasn’t the default, like it is in Bash. Everything else I’ve liked about zsh, but I was confused on why they would repurpose that character here.

Since even in ksh over 3 decades ago, I could just set -o vi, then type out drafts of long commands, then use the hash to comment, and come back them. Every other shell I’ve used has worked this way, and that ^A/# two key combo, I use all too much without even thinking. I thought this was a common thing people did, but as I said, maybe it’s just me.