How to use escape sequences in a ZSH request for truecolor or in bold?

I'm in the middle of setting up my ZSH tooltip, but I can't seem 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, for example %F{000} %f , but as far as I know, these options allow access to the default values ​​(red, blue, etc.) and 256 color palette. While %B %b built-in bold option works, it seems to have only one color.

What I want to do is color the specific section of the tooltip using all RGB colors and / or highlighting in bold. From what I could find, something like this should work:

 PS1="%{\e[38;0;255;0;255m%}%M >:%{\e[0m%}" 

This should give me a pink prompt like this:

 HOSTNAME >: 

But I get the following:

 \e[38;0;255;0;255mHOSTNAME >:\e[0m 

I tried different escape sequences like \033 \x1b but nothing works.

So, how to properly use escape sequences in ZSH requests?



Features:

OpenSUSE Tumbleweed KDE

Konsole --version 16.12.0 (Keyboard: XFree 4)

ZSH -version 5.3

+5
source share
1 answer

You need to change your lines 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 added $

See http://zsh.sourceforge.net/Guide/zshguide05.html for more on lookups .

+2
source

Source: https://habr.com/ru/post/1263120/


All Articles