I have an Ubuntu 12.04 system where I, at reboot, login a root. This morning I did the things I had to and thought about running
apt-get -y upgrade
I started typing this but before pressing Enter I looked at the screen to check for mistyping things, and did see the cursor (blinking underscore) a few spaces after the final e like this (without the actual blinking):
apt-get -y upgrade _
I definately did not type any spaces after the final e. After that I did just press Enter and apt-get ran fine.
I have often seen this happen before and would like to know what might cause this, in order to prevent it from happening again. Alternatively some way to reset this would also be acceptable.
Some details:
- I tried
stty sane, that did not change anything. - Before the
apt-getcommand I did run amountandw. The change happened between starting to typeapt...and the finale - This was on tty2. When I logged out the cursor at the
login:prompt was not at the position, but a few positions off on as well. - Switching to tty1, where I was not logged in, showed the cursor at the wrong position as well.
- I switched back to the GUI (Alt+F7) and back to tty2 and the cursor was still off.
- After looking at tty2 a minute or two later (while writing this Q and wanting to check something) the
login:prompt was still there but now the cursor was at the right position. - I tried to recreate the problem by issuing the same commands (but with different amounts of time between them as before, now directly after each other) and could not get the cursor to bulge from the normal position.
echo $TERMgiveslinuxecho $PS1gives${debian_chroot:+($debian_chroot)}\u@\h:\w\$
This would not bother me so much, but it has happened quite often. When just typing commands it is not such a problem, but it completely confuses me, when it happened and I want to edit some previous command (bash), as then the insertion point is a few positions left from the blinking cursor.
How can I reset the cursor to the right position when this happens? Or preferably: how to prevent this from happening?
\[…\]? IsTERMcorrect?\[..\]in the prompt. And $TERM is linux ( I updated the details list with these two).\[…\], that's the point. Is your prompt in color? Copy-paste yourPS1assignment, or the output ofprintf '%s\n' $PS1 | cat -v