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.

link|improve this question

77% accept rate
feedback

1 Answer

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.

link|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
feedback

Your Answer

 
or
required, but never shown

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