I'm trying to use ANSI escape sequences to set the color of my zsh prompt, but the escape character ( \e) seems to escape when the prompt is displayed. Here is an example of what I run and the output I get:
> autoload promptinit && promptinit
> autoload colors && colors
> echo "Not sure if those two lines are required" > /dev/null
> PROMPT="\e[32mhi> "
\e[32mhi> echo "Note that the escape character wasn't interpreted correctly" > /dev/null
\e[32mhi> print -P "$PROMPT"
hi>
\e[32mhi> echo "The hi> was printed in green, as I want" > /dev/null
The print documentation zshseems to say that the flag -Pforces it to print as if it were in a tooltip, but does not match the actual behavior of the tooltips. Does anyone know why the escape character doesn't work?
I tried to use $fg_no_bold, and things like $fg_no_bold[red]work, but I would like to use more than 8 standard colors, but it $fg_no_bold[32]doesn’t work (for any number, not just 32). If you get 256 colors working with $fg_no_bold, it's easier, then I would do it!
Thank!
source
share