MacOS – Weird OS X Terminal Bug: Cursor won’t go back to end of line after backtracking

cursormacosterminal

I have an interesting problem: when I type something in the terminal as follows:

~ me$ hello<cursor>

and backtrack:

~ me$ he<cursor>llo

and then try to return to the end to continue typing, perhaps after fixing an error, I get stuck before the last character:

~ me$ hell<cursor stuck here>o

Anyone know how to fix this? I've tried looking around and changing the terminal to xterm instead of xterm-256-color, etc. but no luck. Any help is greatly appreciated!

Edit: I am using the arrow keys to move back and forth.

Best Answer

I know this is an old question, but I've been beating my head over this for a few days now and I've finally got it. It turns out the solution is simple: update bash to 4.3. The default bash on Macs (even Yosemite) is 3.2.

Install Homebrew with

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

then do

brew install bash

then change your default shell path (in Terminal Preferences) to

/usr/local/bin/bash

and that's it. Check your bash version with

bash --version

and as an added bonus, you can get mode indicators!

bind 'set show-mode-in-prompt on'

and it will show a + for Insert mode and : for Command mode.