Question

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:

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

The issue is:

  1. I do see "some_long_commands_long_long" on my command line. But the cursor is not located at the beginning, instead it's on the 12nd char, see screenshot enter image description here

  2. 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.

    enter image description here

I searched on google but ended up with nothing..... Anyone has a better idea about this? Thanks a lot...

Was it helpful?

Solution

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 "\]".

OTHER TIPS

Based on comments in Stackoverflow, IMHO the problem is in a tmux/iTerm/settings combination, not in the bash itself. you should try solve the problem step-by-step:

  1. start native Terminal.app with a clean ~/.profile and ~/.tmuxrc
  2. try set -o vi without tmux
  3. if it is works, (should) - switch to iTerm and check again (should works)
  4. start tmux in Terminal.app and in iTerm and compare... both should works.
  5. step-by-step enable your .tmuxrc config...
Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top