Search code examples
zshcommand-promptoh-my-zshiterm2

Zsh – Right prompt shows italic well, but not left prompt


The following is fine:

RPROMPT=$'%{\x1b[3m%} $HISTCMD %{\x1b[0m%}'

However, no italic is shown on left prompt:

PROMPT='%{\x1b[3m%} $HISTCMD %{\x1b[0m%} %{$blue%}%T${PR_RST} %W ♋︎%{$purple%}%n${PR_RST}%{$gray%}@${PR_RST}%{$limegreen%}%m${PR_RST} %{$gray%}${PR_RST}☦︎ %{$magenta%}%~${PR_RST} $vcs_info_msg_0_$(virtualenv_info)
$ '

Solution

  • The RPROMPT is being set to an ANSI-C quoted string with $'...', so escapes and backslashes are being translated to special characters.

    The PROMPT is being set to a single-quoted string, '...'. Every character is being copied literally.

    Change the PROMPT to an ANSI-C string: PROMPT=$'...'.