I have been using oh-my-sh for the past few months, and gosh I love it :), I have noticed there is an array of colors fg_bold[], and by using the array we can echo informative message with colors.

for example: echo $fg_bold[yellow] "Let's make it work!"

Executing this from terminal worked liked a charm.

BUT it seems if I open a brand new zsh script, and copy & paste it, it fails ($fg_bold[yellow] is empty):

#!/usr/bin/zsh #taken from which zsh

echo $fg_bold[yellow] "Let's make it work!"

More to add the fg_bold's array doesn't appear both in env and in printenv. What am i missing here?

Thank you all


That variable is pulled from the colors autoloadable function.

You need to load and run that function:

autoload colors

Note that you can also use prompt expansion which doesn't need that colors function:

print -P %F{red}


echo ${(%):-%F{red}}

In any case, that's an associative array shell variable, not something that can or should be exported to the environment. If you want to see its declaration, use typeset -p fg_bold (note that the variable has the -H (hide value) attribute, so typeset -p would show the values, you can remove that attribute with typeset +H fg_bold, or see the values with typeset fg_bold).

  • Thank you for your in depth answer well appreciated, I just now read the man zshmisc. – JammingThebBits Jul 25 '18 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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