Mac Terminal/iTerm history cursor problems

13

6

So often, I run a command in either Terminal.app or iTerm, press the up arrow to go back to edit it, and the cursor jumps to the line above or somewhere totally in the wrong place. It especially happens when the command is so long that it wraps around to the next line. Sometimes these long commands all appear on one line, and sometimes they display correctly on multiple lines.

This happens in both iTerm and Terminal.app

Also happens in both vi and emacs modes, making them pretty much unusable.

any ideas? thanks!

carillonator

Posted 2010-11-05T00:32:28.230

Reputation: 297

Answers

20

It is most likely because your prompt definition includes sequences that should not be counted in the length of the prompt, such as those for setting colors. These sequences should be between \[ and \] to prevent their length from being counted. Here is an example that produces an all-red prompt:

PS1='\[\033[31m\]\u@\h:\w\$\[\033[0m\]'

Paused until further notice.

Posted 2010-11-05T00:32:28.230

Reputation: 86 075

This line is in the config file (like .bashrc or .bash_profile), for anyone - like me - who is clueless after reading the response. – montrealist – 2016-07-08T16:03:03.673

0

For anyone who having this issue, this bug is fixed. For more info you can visit here. https://code.google.com/p/iterm2/issues/detail?id=2245

You might have to pull the latest source from github and build from source.

https://github.com/gnachman/iTerm2

dhilipsiva

Posted 2010-11-05T00:32:28.230

Reputation: 133