Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

When I open up Terminal (on Mac OS X 10.5.8) and type a long command line: alt text

...the text doesn't go to the next line when it wraps around: alt text alt text

Also, sometimes when I type a command and then backspace (or up-arrow or ^U): alt text

...the entire line isn't erased and I can't backspace beyond a certain point: alt text alt text

Is this a known bash bug (on Mac OS X)? Is there a fix?

Update: Juliano was correct, the problem was caused by incorrectly delimiting a console code sequence in my PS1 variable. Changing:

export PS1='\[\033[1;34m\]\$\]\033[0m\] ' my .bashrc to:

export PS1='\[\033[1;34m\]\$\[\033[0m\] '

...solved the problem.

share|improve this question
+1 for the most beautiful screen shots of a terminal screen I have ever seen. – Dennis Williamson Nov 10 '09 at 21:10
the two code lines you showed in your update are identical. – Magne Oct 2 '13 at 12:27
Good catch, @Magne. It's been four years since I looked at this, so I don't remember specifically, but I assume the "before" was missing a \]. – Daryl Spitzer Oct 2 '13 at 22:01
they are not identical: the 1st one has \] instead of '[` – Ohad Cohen Nov 3 '15 at 13:53
up vote 11 down vote accepted

The behavior is consistent to having console codes in your prompt (to change the color, etc.) and not properly marking then so that bash knows that they are invisible.

Before anything else, do this:

PS1='\w\$ '

And then try again. If the problem is solved, then my suspicions are correct.

Each console code sequence must be delimited with \[ and \] in the PS1 variable. They tell bash that whatever is in there doesn't move the cursor position. Read the bash manual for more information.

share|improve this answer
That was the problem. Thank you! I'll update my question with details. – Daryl Spitzer Nov 10 '09 at 19:58

To help generate a sanitized prompt try it's pretty awesome. Just be careful with brackets in your prompt, it tries to escape them or something.

share|improve this answer
+1 While @Juliano's answer is technically correct, this link here is what sets the correct tput commands - which has fixed newline, `` newline and other "history + backspacing" fixes that using other ANSI codes could not fix. – Eric Duncan Dec 3 '14 at 18:59

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.