I am in the middle of customizing my ZSH prompt but am seemingly unable to use escape sequences to tell Konsole to use bold text or a specific RGB color.
I know about the built in formatting options in ZSH, like %F{000} %f
, but as far as I know, those options only allow access to the defaults(red, blue, etc) and the 256 color palette. While %B %b
, the built-in option for bold, does work, it seems limited to just one color.
What I want to be able to do is color a specific section of the prompt using all RGB colors and/or make it bold. From what I could find, something like this should work:
PS1="%{\e[38;0;255;0;255m%}%M >:%{\e[0m%}"
That should give me a pink prompt like this:
HOSTNAME >:
But what I get is this:
\e[38;0;255;0;255mHOSTNAME >:\e[0m
I have tried different escape sequences like \033
\x1b
, but nothing seems to work.
So, how do I properly use escape sequences in ZSH prompts?
Specifics:
OpenSUSE Tumbleweed KDE
Konsole --version 16.12.0 (Keyboard:XFree 4)
ZSH --version 5.3
You need to change your strings so that zsh evaluates them correctly.
Try changing:
PS1="%{\e[38;0;255;0;255m%}%M >:%{\e[0m%}"
To:
PS1=$'%{\e[38;0;255;0;255m%}%M >:%{\e[0m%}'
Notice the change from "
to '
quotes along with the prepended $
See http://zsh.sourceforge.net/Guide/zshguide05.html for more info on substitutions.
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