Search code examples
zshpromptiterm2oh-my-zsh

How to italicize prompt for zsh (oh-my-zsh, iTerm2)?


I want to italicize my prompt (specifically the right prompt/RPROMPT) for zsh using oh-my-zsh, in iTerm2, and so far have had problems doing so. I have checked that the terminal can output and view italicized fonts with echo -e "\e[3mitalic\e[0m".

Things I have tried so far :

  1. RPROMPT = '\e[3m Hello \e[0m' : the output is a literal quote \e[3m Hello \e[0m
  2. from here, I tried
 HELLO = Hello
 RPROMPT = '\e[3m $Hello \e[0m'`

and the output still has the \e[3m and \e[0m parts

  1. from an example, I tried using \x1b[3m rather than \e[3m : still outputs \x1b[3m and \x1b[0m

  2. I found this page but I don't understand what I'm looking at/what I'm supposed to do.

I would like to get the italic format working, so any help is greatly appreciated.


Solution

  • You can use RPROMPT=$'string with special escaping' (See bash manual)

    It may have a few issues such as the left prompt getting edited.