zdharma-continuum / fast-syntax-highlighting

Feature-rich syntax highlighting for ZSH
BSD 3-Clause "New" or "Revised" License
1.15k stars 75 forks source link

Suppress exit code when zsh/nearcolor is not available #3

Closed agkozak closed 2 years ago

agkozak commented 2 years ago

The last line of fast-syntax-highlighting.plugin.zsh is

[[ $COLORTERM == (24bit|truecolor) || ${terminfo[colors]} -eq 16777216 ]] || zmodload zsh/nearcolor &>/dev/null

The &>/dev/null is clearly meant to suppress an error message when the plugin is used with versions of Zsh earlier than 5.7; they do not have the zsh/nearcolor module. It does not succeed in suppressing the exit code of 1, however, which causes trouble if you're paying attention to exit codes. For the time being, I propose changing the line to

[[ $COLORTERM == (24bit|truecolor) || ${terminfo[colors]} -eq 16777216 ]] || zmodload zsh/nearcolor &>/dev/null || :

The || : should ensure an exit code of 0. fast-syntax-highlight seems to work quite well without nearcolor, though perhaps there are unusual terminals that would beg to differ. I think || : completes the developer's original idea.

pschmitt commented 2 years ago

Good catch. I would prefer a more "explicit" || true though, even it is a bit longer ;)

agkozak commented 2 years ago

Done!