1

I have installed zsh-syntax-highlighting. This works well, except of one oddity: When I type a parameter expansion as a command argument, i.e.

foo $PWD

as soon as I type the $P, the parameter expansion is coloured black (which makes it invisible since I use a terminal with black backroung). It stays black when I type $PW, and turns visible (foreground colour, but underlined) once the $PWD is typed. It seems that the highlight attributes are "fg=black" for an "unfinished/unknown" parameter, but just unline for a known parameter.

I like the fact that they are coloured differently, since I can catch in this way typos in a variable name early. However, black is unreadable, since I also have a black background.

More interestingly, this happens only if the first word in the line is either an external command (like foo in my example), or a syntax keyword (if). It does not happen if the first word in the line is an internal command (such as echo), or an alias invocation, or a function call.

I searched the documentation, but did not find where this colouring of "unfinished parameter expansion" could be defined.

I'm using the following highlighters:

ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern line)

I set various highlight categories, but there is none where I would simply set the foreground to black.

I do some highlighting of very specific parameters, which are important to me, like this:

ZSH_HIGHLIGHT_PATTERNS+=('$(oncoll|onyt|oncp|ong)' 'fg=black,bold,bg=white')

But this also can't have any impact to the problem described here.

Does someone happen to know, which style setting affects me here?

2
  • According to this github.com/zsh-users/zsh-syntax-highlighting/blob/… the only default black is for ZSH_HIGHLIGHT_STYLES[comment], which isn't what you describe, but try changing it, as I don't think you want it in black anyways. It could be also any with none, did you try changing the ZSH_HIGHLIGHT_STYLES[default] one to see if it affects it?
    – Destroy666
    Commented Jul 13, 2023 at 18:49
  • @Destroy666 : It's hard to believe, but it was the setting for comment. After I changed it to something better visible, it worked like a charm. If you post your finding as an answer, I will accept it. Commented Jul 14, 2023 at 6:52

1 Answer 1

1

You can find all the default styles for the main highlighter here.

At this point of time, the only default styling with text (fg) configured to be black is comment.

I don't know why exactly that foo $PW example counts as a comment, but the documentation describes comment as:

comment - comments, when setopt INTERACTIVE_COMMENTS is in effect (echo # foo)
comment - elided parameters in command position ($x ls when $x is unset or empty)

The 2nd condition looks to be in effect as $PW is likely unset.

1
  • 1
    Thanks a lot. This is really interesting, in particular, since undefined parameters in zsh are not really "elided" (when passed to a command, they take up a position in the argument list; they just turn into a null string). Commented Jul 14, 2023 at 8:02

You must log in to answer this question.

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