Mac OS X Lion Terminal cursor problem

In Terminal > Preferences, change xterm-256color to xterm-color:

enter image description here


The problem is that the curses package that is in charge of drawing your screen is miscounting the number of characters because your prompt contains some colour escape sequences.

To see this you can go echo $PS1 at the command prompt and see that it contains something like \[\033[34m\] at either end. This is the colour escape sequence.

The answer is to tell curses the correct terminal type so that it counts properly. Do that in Terminal > Preferences > Advanced - mine is set to xterm256color but any of the xterm choices should work. Note that this setting will only apply to Terminal windows created after you change the setting not any you have open when you make the change.