Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In this thread, yoda suggests the following solution for using colors in zsh

#load colors
autoload colors && colors
    eval $COLOR='%{$fg_no_bold[${(L)COLOR}]%}'  #wrap colours between %{ %} to avoid weird gaps in autocomplete
    eval BOLD_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
eval RESET='$reset_color'

Correct me if I am wrong, but if I understand correctly, autoload colors && colors allows you to call colors by their name, while the rest of the script just wraps them in ${ $}.

This made me think about the following questions:

  1. Is there a way to know what colors are loaded by calling autoload colors && colors?
  2. How do I know what colors are supported by my terminal?
share|improve this question
up vote 2 down vote accepted

The colors function records the names of colors and similar attributes (bold, underline and so on) in the associative array color. This array associates names with terminal attribute strings, which are numbers, e.g. 00normal, 42bg-green, …

echo ${(o)color}

If you want to see how the array is built, look at the source of the function: which colors or less $^fpath/colors(N).

The colors function only defines names and escape strings (in the associative arrays fg and bg) for the 8 standard colors. Your terminal may have more. See this answer for how to explore what colors are available.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.