I customized my prompt in .bash_profile to look like this:

export PS1="\w \e[0;32m\$(vcprompt -f '[%n:%b]')\e[m\$ "

Now, when I press up arrow to go back through history, find the one I want, then press control-a to go to the beginning of the line, it often stops me at the 5th character instead of going all the way to the beginning. Those first few characters are then "frozen" in place. If I arrow up or down from there it's as if those characters are the new $.

I press return and am back to normal, but it's quite irritating to have those characters stuck there! Did I screw something up in the customization? Thank you!

link|improve this question
feedback

1 Answer

up vote 4 down vote accepted

You need to mark the nonprinting sections of the prompt with \[ ... \] so bash can tell they won't take up space on screen. Try:

export PS1="\w \[\e[0;32m\]\$(vcprompt -f '[%n:%b]')\[\e[m\]\$ "
link|improve this answer
That's the stuff! Thanks, Gordon. – Jed Sep 20 '11 at 0:46
feedback

Your Answer

 
or
required, but never shown

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