In this thread, yoda suggests the following solution for using colors in zsh
#load colors
autoload colors && colors
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
eval $COLOR='%{$fg_no_bold[${(L)COLOR}]%}' #wrap colours between %{ %} to avoid weird gaps in autocomplete
eval BOLD_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
done
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:
- Is there a way to know what colors are loaded by calling
autoload colors && colors? - How do I know what colors are supported by my terminal?