After I editted my .bashrc I got ghosts in my prompt

I also had in the past the problem of ANSI colour codes messing up with command line navigation; you need to put the ANSI codes around \[ \] in order for the command shell to know how (not) to take them into account as part of the input string.

As in:

export PS1="\[\e[0;35m\][\u@\h \W]\$\[\e[m\] "
echo -e "\[\e[0;35m\]YOU ARE ON THE LIVE SERVER !!\[\e[0m\]"

Some explanation as to why the shell needs \[ and \]: To draw the prompt in the correct positions in the character matrix of a terminal the shell needs to know the correct length of the prompt string which is the amount of printable characters, i. e. not control characters or character sequences.

However, the shell doesn't know which character sequences the terminal considers printable. Therefore one needs to provide hints to the shell to distinguish between printable and non-printable sequences, which is the purpose of \[ and \].


I've kind of fixed it I used this website http://bashrcgenerator.com/ and did it the long handed way, it's a LOT longer but if you double click the elements you can colour them and it DOES work

I ended up with

   export PS1="\[\033[38;5;129m\][\u@\h\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;129m\]~]\\$\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"