Skip to content

Use proper ANSI code "39" for default color

plg requested to merge plgruener/highlight:plgruener-ansi-colors-patch into master

The method of querying "isDarkTerminal()" via the environment variable COLORFGBG is broken and not supported by all terminals, leading to unreadable text. I suggest to remove it entirely.
If you really need to know if the terminal has a dark or light background, a more reliable way would probably be via the "OSC 4/10/11" escape codes. See eg.

The ANSI color code "39" denotes the default foreground color in any properly configured terminal, and should always be readable on the default background, both for light- and dark-background terminals. (i.e. it should automatically be black for light- and white/grey for a black BG terminal).

It has the same effect as code "0" (normal/reset), but without resetting other text attributes (like bold or underlined).

Merge request reports

Loading