Reputation: 81
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
I thought that something is wrong with my PROMPT
variable, but the prompt looks fine in the terminal inside 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
Upvotes: 3
Views: 1241
Reputation: 11
Like the link by @user3363087,
Method 1
PROMPT=$'%K{236}%F{246}%n%f@%B%m%b %k%K{cyan}%F{236}\Ue0b0%f %F{000}%2~%f %k\e[48;5;256;36m\Ue0b0%f%k %# '
To change the color of the "powerline look" path block, you set the ANSI Cyan value. If you want to change it to green, then replace %K{cyan}
and \e[48;5;256;36m
with %K{green}
and \e[48;5;256;32m
.
Here are the other colors:
Text (m) \033[48;5;256;m
Bold (1m) \033[48;5;256;1m
Black (30m) \033[48;5;256;30m
Red (31m) \033[48;5;256;31m
Green (32m) \033[48;5;256;32m
Yellow (33m) \033[48;5;256;33m
Blue (34m) \033[48;5;256;34m
Magenta (35m) \033[48;5;256;35m
Cyan (36m) \033[48;5;256;36m
White (37m) \033[48;5;256;37m
Method 2
PROMPT=$'%K{236}%F{246}%n%f@%B%m%b %k%K{045}%F{236}\Ue0b0%f %F{000}%2~%f %k%K{236}%F{045}\Ue0b0%f%k %# '
You need replace %K{236}
with the actual value of the background of Terminal.
Upvotes: 0
Reputation: 76
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
Upvotes: 4