History commands render incorrect on Bash Vi mode I'm having this werid and really annoying issue in bash vi-mode.
Env:
Mac 10.9.2, iTerm 2 1.0 or Terminal.app, $TERM={screen-256color|xterm-256color|xterm|vt}
Repro steps:

Run some long commands (like 'some_long_commands_long_long')
Press Esc and then press k.

The issue is:

I do see &quot;some_long_commands_long_long&quot; on my command line. But the cursor is not located at the beginning, instead it's on the 12nd char, see screenshot


If I press A to append some other text, the cursor will go beyond the command, which means the REAL command is start from where the cursor is located at the first place, the rendering is wrong.



I searched on google but ended up with nothing..... Anyone has a better idea about this? Thanks a lot...
After debugging for quite a while I finally figured it out. It's an issue caused by PS1. Basically I forgot to wrap my colored ">" with "\[" and "\]".