20110223

ZSH Colored prompt

Just a quick post because this was driving me crazy : how do you get a colored prompt on ZSH on ubuntu ?

Various suggestions online seemed to fail. It seemed like the escape sequences for getting colored varied wildly, and none worked for me.

I followed the instructions here for loading one of the default prompts. eg :
autoload -U promptinit
promptinit
prompt -l
prompt bigfade
Then, I typed
echo $PROMPT
to see what the proper escape sequences were ( they didn't look like anything provided online ). e.g.:
%B%F{blue}█▓▒░%B%F{white}%K{blue}%n@%m%b%k%f%F{blue}%K{black}░▒▓█%b%f%k%F{blue}%K{black}█▓▒░%B%F{white}%K{black} %D{%a %b %d} %D{%I:%M:%S%P}
%}%B%F{yellow}%K{black}/home/mrule>%b%f%k 
So, apparantly %B gives you bold, %F{colorname} sets the foreground color, and %b and %f return these to defaults ? Anyway, this will give a blue prompt:
%B%F{blue}%~$ %b%f

No comments:

Post a Comment