Method of Editing “bashrc” for Changing the Color of the Prompt in Ubuntu 20.04:
Along with offering multiple other terminal customization options, the bashrc file in Linux can also be edited to change the prompt’s color. For learning the method of doing so, you will have to go through the subsequent steps. However, we would like to mention beforehand that in this method, we will first teach you how to create a backup of the default settings so that you can always restore them whenever you want. After that, we will share with you the method of changing the color of the prompt, and for that, we have shared quite a few examples so that you can see how the prompt will look like after changing its colors. Finally, we have taught you the method of restoring the default prompt color in Ubuntu 20.04. So now, let us get started with the following steps:
Step # 1: View the “bashrc” File on your Ubuntu 20.04 System:
The bashrc file can easily be viewed on a Ubuntu 20.04 system by using any text editor of your choice. Here, we are going to use the nano editor for this purpose, and we will open the bashrc file with the help of the command shown below:
The bashrc file of our Ubuntu 20.04 system is shown in the following image:
In this file, the section in which the attributes of the variable PS1 are defined is important for us. Basically, this variable allows you to customize your terminal in several different ways, along with changing the color of the prompt, which we will learn later in this article.
Step # 2: Take a Backup of the Relevant Variable of this File:
Now, for changing the color of the prompt in Ubuntu 20.04, we will be making some changes to the PS1 variable. However, before doing so, it is highly recommended that you take a backup of that variable so that if you mess up with anything during this whole process or even if you just want to go back to the default prompt color, you will easily be able to do that. For that, we will be copying the value of the PS1 variable to another variable. You can assign any name of your choice to this variable. The command shown below will serve this purpose:
This command will simply assign the default value of the PS1 variable to the TEMP variable, from where it can be restored later. This command will not generate any output upon successful execution.
Step # 3: Change the Color of your Ubuntu 20.04 Prompt from Green to Red:
Now, when we have taken a backup of our PS1 variable, we can easily change it to change the color of our Ubuntu 20.04 prompt. The default color of our Ubuntu 20.04 prompt is green. In this step, we will simply attempt to change this color to red. For that, we will execute the below-appended command: