zsh-syntax-highlighting
zsh-syntax-highlighting copied to clipboard
Document how to reduce colorfulness
Some people find the default colorscheme too colorful (e.g., [1]).
- [ ] Ensure the documentation on changing the colorscheme is clear and findable.
- [ ] Ensure the use of
none
to clear highlighting is documented. - [ ] Is it clear how to determine the name of a highlight style applied to a particular input word?
- [ ] Ensure the use of
- [ ] Consider maintaining some common sets of "less colorful" schemes, either in docs/wiki or potentially as a runtime switch.
One option: support "themes" which are specifications of colors for multiple styles. In main-highlighter.zsh, replace the setting of default styles with
. themes${$ZSH_HIGHLIGHTER_THEME:-default}.zsh
to let people set multiple colors in one shot.
(Idea by @phy1729)
"support "themes...to let people set multiple colors in one shot."
I couldn't agree more with this! Would love it if this support existed
It does, on the themes
branch. Or you can set ZSH_HIGHLIGHT_STYLES by hand.
Is it possible to clear the default styles?
This should do it:
source /path/to/zsh-syntax-highlighting.zsh
() {
local -a new_values; new_values=(none)
ZSH_HIGHLIGHT_STYLES=( ${${(@k)ZSH_HIGHLIGHT_STYLES[(I)*]}:^^new_values} )
}
Not sure how that works but I ended up doing this:
source_if_exists /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
typeset -A ZSH_HIGHLIGHT_STYLES # In case it doesn't exist above.
ZSH_HIGHLIGHT_STYLES=()
# Now my custom theme.
ZSH_HIGHLIGHT_STYLES[reserved-word]="fg=magenta"
ZSH_HIGHLIGHT_STYLES[precommand]="fg=red"
ZSH_HIGHLIGHT_STYLES[commandseparator]="fg=magenta"
ZSH_HIGHLIGHT_STYLES[globbing]="fg=magenta"
ZSH_HIGHLIGHT_STYLES[history-expansion]="fg=magenta"
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]="fg=green"
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]="fg=green"
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]="fg=green"
ZSH_HIGHLIGHT_STYLES[rc-quote]="fg=magenta"
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]="fg=black"
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]="fg=magenta"
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]="fg=magenta"
ZSH_HIGHLIGHT_STYLES[redirection]="fg=magenta"
ZSH_HIGHLIGHT_STYLES[comment]="fg=244"
Seems to work great!
Thanks for sharing your solution!
As to how what I posted works: it uses several parameter expansion flags which, in combination, have the effect of setting ZSH_HIGHLIGHT_STYLES[$k]=none
for every $k
which is an already-existing key of ZSH_HIGHLIGHT_STYLES
. Sorry, I don't have time to post a step-by-step explanation, but the flags are documented in zshall(1) in the sections "Parameter Expansion Flags" and "Subscript Flags".
As to how what I posted works: it uses several parameter expansion flags which, in combination, have the effect of setting ZSH_HIGHLIGHT_STYLES[$k]=none for every $k which is an already-existing key of ZSH_HIGHLIGHT_STYLES. Sorry, I don't have time to post a step-by-step explanation, but the flags are documented in zshall(1) in the sections "Parameter Expansion Flags" and "Subscript Flags".
Makes sense. Thanks for the description.