16 Colors in ZShell

colorsterminalzsh

I only seem to be able to call 8 colors in my zshell prompt.

Example:

PROMPT="[%n@%{$fg[magenta]%}%m%{$reset_color%} %.]
%# "

Works fine. However,

PROMPT="[%n@%{$fg[brmagenta]%}%m%{$reset_color%} %.]
%# "

Doesn't work. Basically, none of the "bright" color variations appear.

After doing some research, I found that zsh's colors are called by the "colors" setopt.

doing

echo ${(o)color}

yields this output:

00 01 02 03 04 05 07 08 22 23 24 25 27 28 30 30 30 30 31 31 32 32 33 33 34 34 35 35 36 36
37 37 39 39 40 40 41 42 43 44 45 46 47 49 bg-black bg-blue bg-cyan bg-default bg-green
bg-magenta bg-red bg-white bg-yellow black blink blue bold conceal cyan default faint green
magenta no-blink no-conceal no-reverse no-standout no-underline none normal red reverse
standout underline white yellow

As you can see, only the standard 8 colors are available. I've tried using the "bg-" variants, which also leave the output as the default text color.

Any help you can provide will be greatly appreciated. I could, of course, just use one of the normal colors, but then I'd learn nothing!

Best Answer

What terminal emulator are you using? You can check the number of supported colors by running echotc Co. For example, my urxvt supports 88 colors, but xterm supports only 8, and bright variations are not included.

If I run it in urxvt I get:

# Dark magenta/violet:
PS1="[%F{34}%n%F{reset}@%F{magenta}%m%F{reset} %.] " 
# Bright Thistle purple:
PS1="[%F{54}%n%F{reset}@%F{magenta}%m%F{reset} %.] "

Sources: man zshall

Related Question