MCC.LU

Line wrap issues in Mac Terminal

March 11, 2015

This has been bugging me for a few months now. When I pressed up arrow to access terminal history the current command would sometimes not be cleared and the command from history would be appended to the end of it. Or if I pasted in a line longer than the terminal width, it wouldn’t wrap to the next line - it would just start overriding the current line from the start.

I finally got to the bottom of it today. Turns out it was down to the way I had defined my prompt in .bash_profile.

“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.”

See here for more information

After redefining my PS1 prompt variable, everything just started to work (and my sanity instantly improved).