zsh-users / zsh-syntax-highlighting

Fish shell like syntax highlighting for Zsh.
github.com/zsh-users/zsh-syntax-highlighting
BSD 3-Clause "New" or "Revised" License
20k stars 1.33k forks source link

Modifying ZSH_HIGHLIGHT_STYLES associative array has no effect #916

Closed willrabbermann closed 1 year ago

willrabbermann commented 1 year ago

At the very bottom of my .zshrc I source.

. /usr/share/zsh/site-functions/zsh-syntax-highlighting.zsh
ZSH_HIGHLIGHT_MAXLENGTH=512

Then from a terminal running my .zshrc I set:

ZSH_HIGHLIGHT_STYLES[cursor]='fg=blue,bg=blue'

This does not change the cursor color.

Then added this to my .zshrc in order to check my terminal (alacritty) for truecolor and load zsh/nearcolor

[[ $COLORTERM = *(24bit|truecolor)* ]] || zmodload zsh/nearcolor

Then reloaded .zshrc and tried this in zsh:

ZSH_HIGHLIGHT_STYLES[cursor]="bg=#006000,fg=#006000"

Still nothing, am I accessing the associative array correctly?

zsh 5.9 (x86_64-pc-linux-gnu)
willrabbermann commented 1 year ago

I initialized the array before use with

typeset -A ZSH_HIGHLIGHT_STYLES

Still no luck

danielshahaf commented 1 year ago

Yes, you are. But you need to enable that highlighter explicitly: ZSH_HIGHLIGHT_HIGHLIGHTERS+=( cursor )

willrabbermann commented 1 year ago

Ok that works, just not so well with alacritty. Its more effective to set the cursor color in my terminal emulator configuration. Setting cursor color in zsh shell is only effective on half of my blinks. Maybe I can configure cursor color when im in a bare tty and not alacritty. Still useful for the other highlight groups, thank you.

danielshahaf commented 1 year ago

Its more effective to set the cursor color in my terminal emulator configutation. Setting cursor color in zsh shell is only effective on half of my blinks. Maybe I can configure cursor color when im in a bare tty and not alacritty. Still useful for the other highlight groups thank you +1:

You're welcome. If there's any bugs or missing features in the cursor highlighter feel free to open a new issue.