Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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'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
up vote 2 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .