Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.