Ask Different is a question and answer site for power users of Apple hardware and software. 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 am used from Linux to have a colored prompt in my shells and also want to implement that in my OS X The Terminal reacts differently though. If I use my normal PS1 code the right side of any line will be cut down at a strange point (surely not the right end of the Terminal window). And also the next line will not show on the next line but on the same line.

expected reaction:

erik2:~[06:46 am]$ expectedexpectedexpectedexpectedexpectedexpectedexpect

real reaction:

ectedexpected_am]$ expectedexpectedexpectedexpectedexp

Is that normal for Terminal? Is there an alternative? Did I just code something wrong? Have a look at my PS1 code:

export PS1="\033[0;34m\u:\W\e[0;32m[\@]\e[m\033[0;34m$\033[m "
share|improve this question
up vote 4 down vote accepted

You need to escape the non-printing parts of the prompt by surrounding them with \[…\].

export PS1="\[\033[0;34m\]\u:\W\[\e[0;32m\][\@]\[\e[m\033[0;34m$\033[m\] "

Otherwise, readline gets confused about the remaining space on the command line.

share|improve this answer

Your Answer


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.