Zsh Color Prompt
A black & white terminal has a certain charme, yet you might be looking for a little more color.
I added color to my zsh
prompt like this by changing my ~/.zshrc
:
export PS1="%F{#C6A0F6}%n@%m :: %~${NEWLINE}%#%f "
There are multiple things going on here. First it starts a color section by providing %F{#C6A0F6}
Everything that follows this code is going to be printed in color, here a shade of purple.
The color code is provided in RGB HEX, as widely used in HTML/CSS styling.
The opening clause %F
has to be closed again, otherwise everything will be printed in purple.
That’s what %f
is doing at the end of the statement.
In summary, everything between %F{}
and %f
is printed in color.
My prompt is divided in two lines separated by ${NEWLINE}
.
The first line contains the username %n
with hostname %m
, as well as the current directory %~
.
The second line just contains a prompt symbol %#
.