Ubuntu – How to change colours in bash prompt

bashbashrccommand lineconfiguration

I have followed the instructions here and in the howto link that is provided there. However nowhere does it appear to say how I can change the colours of the different parts, because currently I set it to:

PS1='${debian_chroot:+($debian_chroot)}[\t] \u@\h:\w\$ '

But the text is still all white, how could I perhaps make the numbers for the time green, and my username and computer name light blue? I am running Ubuntu GNOME 15.04.

Best Answer

First of all, open up your ~/.bashrc file and enable color prompts:

nano ~/.bashrc

uncomment then line #force_color_prompt=yes

Then, change the PS1 line directly under the line if [ "$color_prompt" = yes ]; then

to:

PS1='${debian_chroot:+($debian_chroot)}\[\033[00;32m\][\t] \[\033[01;34m\]\u@\h:\w\$ '  

As you can see, 01:34m is light blue and 00:32m is green. Light green would be 01:32m instead of 00:32m.

Press CTRL + o and then press ENTER to save the file. Press CTRL + x to exit nano.

Then, run the following command to apply the changes by "sourcing" your bashrc file:

. ~/.bashrc

The changes should now apply to every newly opened terminal under your user.

click here for more info