Reputation: 41
According to the ZSH manual, for ZSH V5.1+ colors should be able to be defined as a # followed by an RGB color code as a hexadecimal triplet, for eg. #ff00ff
. However, I have found no documentation that provides a concrete example to demonstrate how exactly this is achieved, and no matter how I try to define a color variable, it never seems to produce the color I want (or any color for that matter). I have tried all of the following formats and none have worked so far when I attempt to use them in %F
or %K
in the prompt definition (eg. PS1="%F{$var} >> %f"
)
var=#ff00ff
var="#ff00ff"
var='#ff00ff'
var=$"#ff00ff"
var=$'#ff00ff'
I am running the shell in the kitty terminal emulator, which has truecolor support enabled by default.
All 255 color numbers (eg. var=231
) in zsh work just fine, color names (eg. yellow
) as well.
I am currently running ZSH V5.5.1.
I have looked for information on the zsh manual page [] and so far nohing more than a mention about it is provided.
I'm looking for an example of how to define hex code colors (and assign them to variables) in no uncertain terms.
Upvotes: 2
Views: 575
Reputation: 41
After some more experimentation, I determined that the problem was partly the documentation, and partly the version. In essence, to declare hex triples in zsh you use the format var='#f0f0f0'
. For this to work it is required that you have ZSH V5.7+, despite what the documentation may say about it working in ZSH V5.1+
I hope this answer will be helpful to anybody else who encounters this difficulty.
Upvotes: 1