Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh prompt configuration for bold colour variants

I have configured my terminal (mintty on Cygwin) to bind colours to certain names, for example

# (Excerpt of .minttyrc)
Green=103,252,66
BoldGreen=53,228,11
BoldAsColour=yes

This configuration works in that I can, for instance, access these colours, when configuring git or nano. However, when I want to configure my zsh prompt, only the non-bold variants work. I guess that I'm using the wrong syntax to refer to the bold colours. Example:

print -P 'X%F{green}ABC%fY'

This displays the letters "ABC" in "my" green, but if I do any of the

print -P 'X%F{bold green}ABC%fY'
print -P 'X%F{boldgreen}ABC%fY'
print -P 'X%F{bright green}ABC%fY'
print -P 'X%F{brightgreen}ABC%fY'

the whole string is displayed in the normal foreground colour, which likely means that the colour name is not recognized.

I also tried

print -P 'X%B%F{green}ABC%f%bY'

but this does not use the BoldGreen value and instead displays ABC in a - eh - bolder font.

Could someone explain to me, why this happens, and suggest a workaround?

like image 515
user1934428 Avatar asked Nov 08 '22 00:11

user1934428


1 Answers

You can use the numeric form of %F to access the bright versions of the 8 standard colors. This for-loop will list each base color with its corresponding bright version:

for c in {0..7}; do 
  b=$((c+8))
  print -P - "%F{$c}$c%f -> %F{$b}$b%f"
done

So, for example, whereas %F{2} will give you base green, %F{10} will give you bright green.

More info here under %F (%f) and here under fg=colour.

like image 108
Marlon Richert Avatar answered Dec 05 '22 07:12

Marlon Richert