On my system, when using a colorized prompt, the last line of the previous command's output gets overwritten if the last character of the output isn't a newline.
Ex: Using the default, non-colored bash prompt, we have:
[myusername@myhostname dirname]$ echo -n foo-bar foo-bar[myusername@myhostname dirname]$
This is expected.
However, using the following colorized prompt:
PS1='\[\033[1;32m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]\$ '
we have (shown here without the color):
myusername@myhostname:~/path/to/dirname$ echo -n foo-bar myusername@myhostname:~/path/to/dirname$ rname$
The cursor is now located on the last "r" in the line. Typing some characters at the prompt overwrites the last "rname$". The end result is that if the previous command's output does not end in a newline, I cannot see what it is. This is the most important thing to fix. The way the extra characters appear, but are over writeable, doesn't bother me much, but would also be nice to fix.
I've tried this with other colorized prompts from bash documentation, and some colored prompts from other super user answers regarding colorized prompts, and they all behave the exact same way.
$ bash --version GNU bash, version 3.1.17(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2005 Free Software Foundation, Inc.
Not sure, but I think it's CentOS, don't know what version. Give me a command to check the O.S., and I'll run it.
PROMPT_COMMAND
to see if the behavior persists. It would also be helpful if you specified your bash version (runbash -- version
) and your OS.unset PROMPT_COMMAND
doesn't help.$ echo $PROMPT_COMMAND
givesecho -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"