views:

355

answers:

1

I currently have my ZSH PROMPT variable set up as:
PROMPT=$'[%{\e[0;32m%}%n@%m:%~%{\e[0m%}]>

and my RPROMPT variable as:
RPROMPT=$'[%{\e[0;32m%}%T\e[0m%}]'

The effect I'm working for is to make the brackets and ">" white (using Terminal text-color settings) and everything inside of those green. However, when RPrompt is enabled in OS X (Ubuntu works fine), text entry begins 3 characters INTO the LPrompt, and overwrites the last 3 characters!!

Screenshot

What is the proper way to color my ZSH Prompt and RPrompt to avoid this issue?

+1  A: 

Your RPROMPT messes up for me on Ubuntu. Since zsh knows ANSI color sequences and has its own facility for that (which automatically takes care of zero-width correction, too), try this:

RPROMPT='[%F{green}%T%f]'

And, by the way:

PROMPT='[%F{green}%n@%m:%~%f]>'
Dennis Williamson
That fixed it right up - I love simple solutions! Thanks!
ConnorG
There's nothing in the PROMPT definition which warrants $'...' instead of just '...'; the $'...' form interprets echo/print escapes when setting the value of the string (and you're missing the trailing ' too, obviously).
Phil P
Oops, I simply copied and pasted what was in the OP's question.
Dennis Williamson