How to Change Your Prompt in Bash Shell in Ubuntu

I do not like my timely, i want to change it. it has my username and host, but the formatting is not what i desire. This blog will certainly obtain you began rapidly on doing specifically that.

This is my current timely listed below:

To change the punctual you will certainly update bashrc and establish the PS 1 environment variable to a brand-new worth.

Here is a cheatsheet of the prompt choices:

You can make use of these placeholders for modification:

u– Username
h– Hostname
w– Present working directory site
W– Basename of the current working directory
$– Reveals $ for a normal user and # for the root user
t– Present time (HH: MM: SS)
d– Date (e.g., “Mon Jan 05)
!– Background variety of the command
#– Command number

I intend to alter my prompt to claim
Right here is my new punctual I am mosting likely to use:

export PS 1 =”linuxhint@mybox w:”

Can you guess what that does? Yes for my post writing this is specifically what i want. Here is the screenshot:

A lot of people will desire the Username, Hostname, for my example i don’t! However you can utilize u and h for that. I made use of w to show what directory i remain in. You can likewise show day and time, and so on.

You can additionally have fun with establishing colors in the timely with these variables:

Foreground Color styles:
e [30m – Black
e[31m – Red
e[32m – Green
e[33m – Yellow
e[34m – Blue
e[35m – Magenta
e[36m – Cyan
e[37m – White

Background Colors:
e[40m – Black
e[41m – Red
e[42m – Green
e[43m – Yellow
e[44m – Blue
e[45m – Magenta
e[46m – Cyan
e[47m – White
Reset Color:
e[0m – Reset to default

Here is my colorful version. The backslashes are primarily needed to ensure proper formatting of the prompt and avoid breaking its functionality.

export PS1=”[e[35m] linuxhint [e[0m] @ [e[34m] mybox [e[0m] [e[31m] w [e[0m]:”


This makes use of Magenta, Blue and Red coloring for various components of the punctual.

Final thought

You can see how to personalize your bash prompt with PS 1 environment in Ubuntu. Hope this aids you enjoy with your atmosphere in linux.

Leave a Reply

Your email address will not be published. Required fields are marked *