Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to italicise text in zsh prompt?

Tags:

zsh

prezto

I'm struggling to understand how to italicise a section of my zsh prompt (using prezto).

My prompt currently looks like this:

PROMPT='%F{yellow}%T %F{magenta}${SSH_TTY:+%n@%m }%F{cyan}%1~%f${vcs_info}\ 55 %(!.%B%F{red}#%f%b.%B %(?.%F{green}.%F{red})❯%f%b) '

Say I wanted to make the vcs_info italic, how would I do that?

like image 920
tanc Avatar asked Feb 03 '26 16:02

tanc


1 Answers

In theory, the ANSI escape code \e[3m sets the italic SGR. So to answer your question, this should work:

PROMPT='...%{\x1b[3m%}${vcs_info}%{\x1b[0m...%}'

Unfortunately, italic text is not widely supported in terminals emulators. Some just ignore it, others inverse the colors instead of italicizing text. To test your terminal emulator, check the output of echo -e "\e[3mitalic\e[0m". If that doesn't print italic, you need to use a terminal emulator that does, such as gnome-terminal.

like image 109
kba Avatar answered Feb 05 '26 06:02

kba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!