OS: Linux

You should be familiar with Bash prompt if you are a linux user. Whenever you start a terminal the command line interface of the Linux server you should be using Bash as a default unless you have change the default shell to something else.

Bash prompt is set by the environment variable PS1 (Prompt String 1). The variable is configure by default using the settings in /etc/.bashrc , you should be changing the user prompt in the user directory if you want to change the prompt that the user will see. /home/<user>/.bashrc

The file should be hidden by default. So you might want to use ls -a to see the file.

To see the current PS1 value you can use the command echo $PS1. Here is a sample output of the prompt in Debian.

To change the prompt temporally you can use the following command. PS1=”<Enter the Values>”

It is useful if you are writing a blog like me or doing a video and you want to highlight certain key attributes or differentiate users or system.

Here are a list of common values.

ValuesDescription
\uUsername
\hShort hostname
\WBasename of the current working directory ~ for home or root
\sShell name (base or sh)
\vThe shell’s version
\wThe whole path of the directory (Similar to pwd command)
\dDate
\D{format}Custom date
\D{%c}The date and time in the current locale
\nNew line
\!History number

Using the color values. \e[

ValuesDescription
\e[Is an escape character. What follow is the values to change the colors.
Start color scheme
\e[mEnd the color scheme
x;yColor pair. x determine the brightness.
To make red brighter you can start with 0 or even -1
y is the color eg. 30 is black.
30Black
31Red
32Green
33Brown
34Blue
35Purple
36Cyan
37White
38Orange
39Yellow

Example of Black and Blue