bad interaction with custom prompt and beginning-of-line
From:
Robert Anderson
Subject:
bad interaction with custom prompt and beginning-of-line
Date:
Fri, 4 May 2007 15:57:38 -0700
I use bash and have a custom prompt that includes some coloring (which includes non-printing characters, of course).
When in an xterm, I can always use ctrl-a (beginning-of-line) to return to the beginning of the line, and it always goes to the correct cursor position.
When I start screen, if I have text that wraps onto more than one line, and I use ctrl-a, it backs up too far, into the middle of the prompt. If cursor forward, the prompt is overwritten by the text as if it was shifted left a few characters.
Is there any way I can work around this, other than removing the non-printing characters from my prompt?
Here's an example prompt you can try:
PS1="\[\e[0;42m\u\e[0;49m\] "
which is just your username in green followed by a space. Try typing a line that wraps, and then do beginning-of-line.