5

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?

user1934428
  • 19,864
  • 7
  • 42
  • 87
  • Check this: [How can I change the color of my prompt in zsh (different from normal text)?](https://stackoverflow.com/questions/689765/how-can-i-change-the-color-of-my-prompt-in-zsh-different-from-normal-text) – Kousic Nov 19 '18 at 06:26
  • Thanks for pointing out the link. While it doesn't show which color *name* could be used for my problem, it indeed pointed out a workaround by using suitable escape codes: For instance, `print -P $'X\e[0;92mABC%fY'` would display *ABC* in bright green - I was not aware of the 90-97 range of the ANSI colour codes. – user1934428 Nov 20 '18 at 06:41
  • 1
    %B and %b does work to bold for me in zsh – cmd Sep 09 '21 at 22:02

1 Answers1

1

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.

Marlon Richert
  • 5,250
  • 1
  • 18
  • 27