Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an adjusted prompt in my ZSH-configuration. Main feature is, that this prompt is colored red, so that I can easily it distinguish from the outputs of programs. My prompt is defined as follows:

PROMPT=$'\e[0;31m%n@%m:%~> \e[0m'

This works mostly fine, but sometimes my cursor switches to another position on tab-completion and some characters are left behind on the screen and mangle up the commandline. That is a little annoyance, but if someone knows a solution for this, I would appreciate it.

share|improve this question
up vote 2 down vote accepted

You need to wrap the non-printing sequences in %{ ... %}:

PROMPT=$'%{\e[0;31m%}%n@%m:%~> %{\e[0m%}'

You should be able to do:

PROMPT=$'%F{red}%n@%m:%~> %f'

which is simpler, easier to read and will work with terminal types that use different escape sequences.

share|improve this answer
The second line doesn't work for me, but the first works great. Thank's alot! – Mnementh Mar 25 '10 at 13:00
@Mnementh: Sorry, there was a typo in the second line - the "F" was missing. Try it now. – Dennis Williamson Mar 25 '10 at 14:25
Thanks, now work both lines. I would upvote again, if I could. :-) – Mnementh Mar 25 '10 at 15:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.