ZSH color prompt - not working

I am going through the zhguide_us.pdf file from zsh.org. The guide indicates that the prompt's color can be customized using tags in the .zshrc file.

Quoting from the manual,
In the case of colours, there is a shell function colors supplied
with the standard distribution to help you. When loaded and
run, it defines associative array parameters $fg and $bg which you
use to extract the escape sequences for given colours, for example
${fg[red]}${bg[yellow]} produces the sequences for red text on a
yellow background. So for example,

PS1="%{${bg[white]}${fg[red]}%}%(?..(%?%))\
%{${fg[yellow]}${bg[black]}%}%# "

I can't get these color tags to work. Anyone had luck with this? Thanks.

MBP 1st generation, Mac OS X (10.5.7), Safari 4.0

Posted on Jun 26, 2009 5:54 PM

Reply
Question marked as Top-ranking reply

Posted on Jun 27, 2009 6:32 PM

Which means I probably need to have something like "autoload -U color" called prior to color coding the prompt? In the .zshrc file?


You both need the following two lines in your .zshrc:

autoload -U colors
colors

The zshguide.pdf says:
"When loaded and run, it defines associative array parameters $fg and $bg ...."
4 replies
Question marked as Top-ranking reply

Jun 27, 2009 6:32 PM in response to oxomoxo

Which means I probably need to have something like "autoload -U color" called prior to color coding the prompt? In the .zshrc file?


You both need the following two lines in your .zshrc:

autoload -U colors
colors

The zshguide.pdf says:
"When loaded and run, it defines associative array parameters $fg and $bg ...."

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

ZSH color prompt - not working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.