Changing your BASH prompt

Your BASH prompt is defined by the $PS1 environment variable. You can view the current setting by running the following command:

echo $PS1

This will ouput a string such as:

\\u@\\h:\\w\\$

Here is a list of the most commonly used escape characters:

\\h the hostname up to the first `.'
\\H the hostname
\\s the name of the shell, the basename of $0
(the portion following the final slash)
\\u the username of the current user
\\w the current working directory
\\W the basename of the current working directory
\\! the history number of this command
\\$ if the effective UID is 0, a #, otherwise a $

(Please check the BASH man page for the complete list)

To set a new prompt string you can just export a new value of $PS1 using the following command:

export PS1="\\u@\\h:\\w\\$ "

To make this permanent you will need to add the above command to a global startup file or your ~/.bashrc

To use colours in your prompt you will need to use the following escape sequence:

\\033[1;31m\\]

This will set all proceeding text to light red. You will need to use a similar escape sequence to set the colour back otherwise all your terminal text will be in light read,like so: