I'm colorizing parts of my bash prompt using ANSI escape sequences. This works great, until the command I'm currently typing in is long enough that it has to wrap. Instead of the rest of the command displaying on the next line, it wraps back to column 1 of the current line, overwriting the beginning of the prompt.

That did it. The reason, it turns out, is that bash needs to be told "the following characters are non-printable" so it doesn't become confused over the length of the prompt. This is done by enclosing non-printable characters in \[ and \]. See tldp.org/HOWTO/Bash-Prompt-HOWTO/nonprintingchars.html
–
Eric J.Apr 12 '10 at 20:13