Foreground and background color rendered differently in macOS Terminal.app

774 Views Asked by At

I tried to build some simple custom prompt for zsh inspired by the 'powerline look'. My .zshrc currently looks like:

CLICOLOR=1
PROMPT=$'%K{236}%F{246}%n%f@%B%m%b %k%K{045}%F{236}\Ue0b0%f %F{000}%2~%f %k%F{045}\Ue0b0%f %# '

However, I noticed color differences between the background color of the path and the foreground color of the following triangle (both set as 045), as can be seen in the following screenshot Prompt in macOS Terminal.app

I thought that something is wrong with my PROMPT variable, but the prompt looks fine in the terminal inside VSCode: Prompt in VSCode

It seems as if Terminal.app is darkening the background color for some reason, but I don't find a way to turn this off. Is this possible or can I modify my PROMPT in some way that prevents the problem?

EDIT: I use the font "Hack" that can be found here: https://sourcefoundry.org/hack/

Thanks in advance, Philipp

1

There are 1 best solutions below

0
On BEST ANSWER

The problem is that the MacOS Terminal app has a weird feature where it renders text against the terminal's default background differently. If a background color is explicitly specified then the foreground colors are all slightly different to what they are when there is no background color specified or it has been reset to default.

This is the same issue as below. Check there for better discussion and a potential workaround. https://apple.stackexchange.com/questions/282911/prevent-mac-terminal-brightening-font-color-with-no-background/446604#446604