How to customize the Bash terminal prompt in Debian 10

The bash Linux shell provides many customization options for the prompt, which you can use to not only include different features in the prompt, but also to distinguish them with different colors.

In this article, we will use various examples to customize and change the tooltip color of our terminal application, allowing you to do the same depending on your needs. We have the commands and procedures outlined in this article on a Debian 10 Buster system.

Viewing the current bash prompt configuration

When you open your Terminal by searching for Debian Application Launcher, you see the following prompt:

[email protected]:directory$

This format defaults to the username, hostname, and then the user’s current directory. Bash takes this configuration from a bashrc file, which is configured individually for each user in their home directory. This is how you can open this file:

$ nano ~/.bashrc

Location: /home/username/.bashrc

You can also use any other text editor to open this file.

This is what this config file looks like. Here we show you the relevant part of the file.

Edit bashrc with nano editor

The PS1 variable you see in the image above has all the necessary configuration for the bash prompt. Let’s first explain what the symbols in this variable mean. You can clearly see this variable in the PS1 variable listed after the else statement.

  • u – Specifies the name of the current user.
  • h: specifies the hostname of the current user, extracted from the fully qualified domain name.
  • w: indicates the current working directory. Your home directory is denoted with a tilde ~.
  • $]indicates whether you are a regular user ($) or a root user (#).

You can also view the configuration of the PS1 variable by repeating its value as follows:

$ echo $PS1

PS1 variable

Customize Bash prompt

Having seen where the tooltip information is stored and what the PS1 variable describes, let’s see how it can be edited to customize our bash tooltip.

Before editing the PS1 variable, it is important to save its default contents in a new variable. This will help us restore the original prompt configuration if something goes wrong. Enter the following command in Terminal:


The DEFAULT variable now contains all the information needed to restore our default prompt settings.

Let’s now experiment with our PS1 variable. Enter the following command:

$ PS1="u$ "

This new PS1 value affects your tooltip as follows:

You can only see your username and root user information without any colors as the color information has not been set yet.

Let’s enter the following command so that our prompt will also include our working directory

$ PS1="u:w$ "

This new PS1 value affects your tooltip as follows:

Working directory list

Since my working directory was home, I could only see the ~ symbol. In another directory, say Pictures, my prompt will show the following information:

Individual prompt

Set the prompt to the default

Since we saved the original PS1 configuration in the DEFAULT variable, we can return PS1 to its default value by passing it the value of our DEFAULT variable.

Return the default hint

What else can you customize?

If you want your invitation contain certain custom text, you can use the following syntax:

$ PS1="[custom text] [email protected]h:w$ "


I configured my invitation to include my own message like this:

Customize command line text

You can include the following basic symbols in the tooltip:

The characterpurpose
dDate in the format day month date.
butEscape character.
hourThe hostname of the current user before ‘.’
HOURThe hostname of the current user.
lThe base name of the target.
jThe number of jobs performed by the shell.
RCarriage return.
PNew line.
uThe username of the current user.
vBash version.
!Print the history number of the command being executed.

You can enable current system time at the command line with the following command:

$ PS1=”Au: w$ “

This new PS1 value affects your tooltip as follows:

Show time on command line

You can also customize your prompt to include command output; this gives you unlimited possibilities to be included in your prompt.


$ PS1="[email protected]h on `[command]` w$ "


In this example, I’ll customize the hint to include the name of the primary group the current user belongs to.

$ PS1="[email protected]h on `id -gn` w$ "

Show command output in tooltip

Color the Bash prompt

After setting up the hint, you realize that things might look a little wrong. The simple reason is that it is not easy to distinguish one function from another if they are all in the same color. Now let’s find out how to colorize the tooltip to make it more pleasing to the eye.

To add colors to one or more functions, the PS1 variable includes color tags. The highlighted text in the following image is a color cue.

Add colors to command line

This is the color label format:


For example, the default username and hostname we see in our default terminal prompt are green due to the following color tag:

[33[01;32m][email protected]h

You can change this color value for the bash prompt function to give it a new color, or add a new color tag to a function that doesn’t have one.

Here are some common colors and their meanings:

red31 year
Purple35 year


The following command will turn the prompt red because we are specifying 31 (red) in the color tag:

$ PS1="[33[31m][email protected]h:w$ "

Colorize Bash Tooltip

Using Text Styles in Bash Prompt

You can add styles to the invitation text by assigning an attribute value to the color tag. Here is the format of a color tag with an attribute:


The following attribute values ​​can be used for the prompt text:

Attribute valuepurpose
0Plain text (this is the default, even if the attribute is not set)
oneIn a Debian terminal, this value stands for bold text.
2Faint text
fourUnderline text
fiveFor blinking text
7Swaps the color of the text and background
eightFor hidden text


You can use the following command to underline the bash prompt:

$ PS1 = ”[33[4;31m][email protected] h: w $ ”

A value of 4 indicates that we want to “underline” the text.

Text Styles

Make permanent changes to the tooltip

The commands you have run so far will only change the prompt for the current bash session. After you have experimented with customizing the text and coloring of your prompt and have reached the final you want to set permanently for all your bash sessions, you need to edit the bashrc file.

Open the .bashrc file and copy the final PS1 value to the PS1 line under the if; then the line. In the following image, I just changed the bash prompt color to red:

.bashrc file

Save the file by pressing Ctrl + X followed by Y. The changes to the bash prompt will now be permanent. Exit Terminal and reopen it to see that your bash prompt is still the same as you set it.

Change bash prompt color permanently

With practice in this tutorial, you should be able to succeed in setting up the bash prompt. You can then adjust the colors to differentiate between the different features that you have included in the tooltip. This way you will be able to view and use this useful information every time you use the bash command line.

How to customize the Bash terminal prompt in Debian 10

Related Posts