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'm trying to customize my bash prompt on Mac OS X. Here is what I put in .bash_profile:

$ cat .bash_profile
export PS1="\e[0;36m\u : \W \$\e[m "
#...

I got the prompt I wanted but when I enter a long command, all is written on a single line. At the end of line, it starts back at the beginning.

How can I improve my custom PS1 to wrap long commands over to the next line?

share|improve this question
    
possible duplicate of Linux: coloring bash prompt will broke carriage return –  grawity Jan 10 '12 at 11:55
add comment

1 Answer 1

up vote 1 down vote accepted

You need to wrap the formatting sequences that will not actually be printed in \[ and \] so that the length calculations don't break. More about it here in the section Colors.

share|improve this answer
    
It's \[ \] for the calculations; \e[ is the formatting sequence itself. –  grawity Jan 10 '12 at 11:56
    
@grawity Thanks. Got it right in the linked post, at least :-) –  Daniel Beck Jan 10 '12 at 12:01
add comment

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.