iTerm2 cursor doesn't return to line beginning I'm not sure if I'm missing some sort of configuration here, but occasionally my cursor is unable to return to beginning of line where command starts. If I press FN+leftArrow, it goes few characters after beginning of command, if I press FN+rightArrow, ot goes way behind end of line. It seems like it thinks that whole line is shifted to the right. See screenshots attached. I was unable to reproduce this on purpose. It happens woth all kind of different commands pretty nondeterministically :-(. Any ideas are welcomed, thanks.
 


Matthew
So our debugging session has determined it is your prompt customization, not iTerm2. You said your prompt customization is:

export PS1="$(tput bold)$(tput setaf 6)\t [\W]$(tput sgr0): "


The simple answer is don't use tput to customize your prompt. It's the sgr0 reset command that's likely doing more than you want it to do and screwing up buffered text movements.

Let's try doing this with ANSI codes directly. If you use an ANSI color scheme setup like this you can try:

export PS1="${normal}${bold_blue}\t [\W]${normal}: "


That works perfectly for me with Fn-arrow combinations for navigating the line.

tput is a neat idea, but it comes from the ncurses package which is a very advanced way of doing UIs in command prompt interfaces by exploiting all kinds of terminal stuff. Best to just stick to ANSI here.