Editing to Clarify: I have seen issues like this in the past due to incorrect escaping of non printed colors. In my case it was due to not having \[
in front of each escape sequence in your case it may be more to do with not recognizing '\e' so i would recommend replacing \e with \033 making sure that you always have [\033 in front of each [x;yzm] for your colors. I presume \e[m\]
is meant to disable colors, I would use"\[\033[0m\]"
for this instead (mostly because i know it works in all cases) You may consider setting this as a variable in the same way i have below with PMT_Color_Off
to tidy up your prompt and make it easier to debug. I have shown examples of what i do below.
I am escaping my colors like so PMT_Red="\[\033[0;31m\]"
where as for non prompt it is just Red="\033[0;31m"
To turn the color off I use PMT_Color_Off="\[\033[0m\]"
and Color_Off="\033[0m"
for non prompt
a working copy of the prompt on one of my development machines is
export PS1="\[\033[01;33m\]$(ifconfig | grep "inet" | grep -v "127.0.0.1" | awk '{print $2}' | awk -F: '{print $2}') \[\033[01;32m\]\u@\h \[\033[01;34m\]\[\033[01;33m\]\w #\[\033[00m\] "
http://www.askapache.com/linux/bash-power-prompt.html also uses the \033 escape rather then \e
I have tested mine on several terminal emulators including xterm, gnome-terminal, terminology and the frame buffer