Well, I think you know pretty well what I'm talking about; if not, check this video. Basically, when you press your up array to obtain the previous command, often the characters are left on the terminal. Is there any way to circumvent the problem?
EDIT: This problem doesn't happen with gdb
only, but also with a normal terminal. This should be the interesting lines in .bashrc
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
EDIT2: Ok, I'll try to explain it with an example. Suppose you have this terminal history (pretty simplified for the sake of simplicity):
user:host$>cd foo/bar
user:host$>sudo apt-get dist-upgrade
user:host$>clear
user:host$>
Then, if you press your up arrow key 3 times, you are expecting something like
user:host$>cd foo/bar
but you are obtaining instead
user:host $>sudo apcd foo/bar
This is the least funny scenario you can end up with, I must admit; sometimes there are a so complex mosaico on the screen that you want to crash anything. I don't know which is the cause, I think I probably bad formatted something in the .bashrc
file, but still I don't know what.
However, changing the previous .bashrc
lines to something like this
if [ "$color_prompt" = yes ]; then
PS1='\[\033[1;31m\]\u:\[\033[1;37m\]\W\\$>\[\033[0;32m\]'
PS2='\[\033[1;37m\]>\[\033[0;32m\]'
else
PS1='\u:\W\\$'
PS2='>'
fi
the problem partially disappears: it's not happening anymore in normal shell, but if I launch gdb
for example it happens most of the time. Can it be related to the special characters?
EDIT3
Here are the relevant lines in ~/.gdbinit
file; you can find the whole file here. Maybe the final \]
string is missing, isn't it?
if $USECOLOR == 1
# BLACK
if $arg0 == 0
echo \033[30m
// a lot of other if-else conditions
\[
and\]
, or\x01
and\x02
(not sure which), omitting these is a typical problem with color bash prompts that leads to pretty much the same behavior as seen in this video.\[
and\]
whatsoever in the file you linked. I've probably missed to double-escape these chars, e.g. try\\[
,\\]
or something along these lines. You should try\001
and\002
too, probably readline requires these.