I'm having some difficulty configuring my zsh prompt. Specifically I would like the font to have the color defined by the hex code: #87afdf
Currently, I've set up the prompt as follows:
PROMPT='%B[%d]
➞ %b'
I've attempted to add colors in the following way:
autoload -U colors && colors
PROMPT='%{$fg[#87afdf]%}%B[%d]
➞ %b%{$reset_color%}'
But this only gives me the following gibberish:
$fg[#87afdf][/Users/gregory]
➞ $reset_color
Any ideas on how to proceed would be very much appreciated.
To customize the ZSH prompt, we need to modify the prompt= variable inside the . zshrc file. We can populate the prompt variable with various placeholders, which will alter how the ZSH prompt appears.
To make any change to the default zsh prompt, you'll have to add relevant values for the prompt to appear differently than the default. It'll be blank if you're accessing it for the first time. You can add a new line with the text PROMPT='...' and include relevant values in the ellipses.
You have to use a 256-color palette. You can see the numerical values for each of the 256 colors in ZSH using the following command:
for code in {000..255}; do print -P -- "$code: %F{$code}Color%f"; done
The same for bash:
for code in {0..255}; do echo -e "\e[38;05;${code}m $code: Color"; done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With