If you have accidentally modified the PS1 value or want to restore it to its default, follow the steps below. This guide will walk you through the process of restoration on Linux systems, including distributions like Debian and Ubuntu.
The PS1 variable defines the format of your terminal prompt, which is the text that appears before you can enter commands. If you notice that your terminal prompt has changed or is showing incorrect information, the PS1 value might have been altered.
The file that configures the terminal prompt is .bashrc, located in your home directory (~). To restore PS1, we need to edit this file.
Now, you need to open the .bashrc file to restore the PS1 value. Depending on your preference, you can use either nano or mousepad. Both are text editors available in most Linux distributions. Below are the instructions for each editor:
nano is a simple, easy-to-use text editor. Here’s how to use it to edit your .bashrc file:
- Open a terminal and type the following command:
sudo nano ~/.bashrc - Uncomment the
PS1line by adding a#at the beginning of the line. This will disable the currentPS1value:
# PS1='...'- Above the PS1 line, add the following line to customize your terminal prompt:
PS1='\n\[\e[38;5;43m\]┌──(\[\e[38;5;33;1m\]\u㉿\H:\[\e[0;38;5;43m\])-[\[\e[0;1m\]\w\[\e[0;38;5;43m\]]\n└─\[\e[38;5;33;1m\]\\$\[\e[0m\] ' - To apply the changes you just need to press
Ctrl+Xand before to made the .bashrc file, run you will need to put this command on the terminal:
source ~/.bashrcThis will reload the .bashrc file and apply the new PS1 prompt.
sudo mousepad .bashrc This option is much easier because you don’t have to tab through the sections; you can go directly to it, and you can even search for it by pressing Ctrl+F, you will search "PS1" and you will gonna click the down arrow on the interface.
Once you have located the PS1, you will do the following:
-
Uncomment the
PS1line by adding a#at the beginning of the line, which will disable the function from running. -
Then, above the
PS1line, add the following line to set your custom prompt:PS1='\n\[\e[38;5;43m\]┌──(\[\e[38;5;33;1m\]\u㉿\H:\[\e[0;38;5;43m\])-[\[\e[0;1m\]\w\[\e[0;38;5;43m\]]\n└─\[\e[38;5;33;1m\]\\$\[\e[0m\] ' -
Once you have made the changes to the
.bashrcfile, save it:- You can either click the Save button in the top menu of your editor, or simply press
Ctrl + Sto save the file.
- You can either click the Save button in the top menu of your editor, or simply press
-
After saving the file, apply the changes by running the following command in your terminal:
source ~/.bashrc