1

So I edited my .bashrc and decided to add the following code:

bold=$(tput bold);
if [ "$EUID" -ne 0 ]; then
    PS1="\[${bold}\e[38;2;171;178;191m[\e[m\]";
    PS1+="\[${bold}\e[38;2;97;175;239m\u\e[m\]";
    PS1+="\[${bold}\e[38;2;152;195;121m@\e[m\]";
    PS1+="\[${bold}\e[38;2;198;120;221m\h: \e[m\]";
    PS1+="\[${bold}\e[38;2;86;182;194m\w\e[m\]";
    PS1+="\[${bold}\e[38;2;171;178;191m]\e[m\]";
    PS1+="\[${bold}\e[38;2;229;192;123m$ \e[m\]";

else PS1="[${bold}\e[38;2;224;108;117m[\u@\h \W]# \e[m]"; fi

After doing so, the colours are working just fine however, after a quarter of the second line is completed, it sort goes back to the start of the second line and overwrites whatever was written over there and the moves on. I'm sure this is some sort of syntax error on my part, not sure what it is.

  • This is probably because you keep adding the bold and never turn it off, but what is the final PS1 you are trying to create? – terdon Aug 03 '20 at 18:32
  • This is pretty much https://unix.stackexchange.com/q/317734/5132 again. – JdeBP Aug 03 '20 at 18:34
  • Could you try and explain what the prompt should actually look like, what you're trying to achieve? – Artur Meinild Aug 03 '20 at 18:41
  • I'm trying to achieve [username@hostname: ~]$ where the username, @, hostname and the two brackets and $ are in different colours – xMaverick Aug 04 '20 at 04:35

0 Answers0