How to display the Prompt (PS1) of the Linux Terminal with colors?

How to display the Prompt (PS1) of the Linux Terminal with colors?

How to display the Prompt (PS1) of the Linux Terminal with colors?

Since today is Friday, the second of the month of May, and surely many fans of Linux and the Linuxverse in general usually show off your usual Desktops and Terminals (Consoles) with attractive graphic designs (Wallpapers) and useful and important elements or information based on your operating system; Today we will take the opportunity to show you an interesting customization trick.

And basically, it consists, as the title of our article today says, in coloring the prompt of our Linux Terminal with colors. And to do this, as our featured image says, we will be using the terminal command called “lolcat”, which we usually use mainly to color the “Fetch” of our free and open operating system when we show it on those great days of #DesktopFridays. So, below we will show you «How to show the Prompt (PS1) of the Linux Terminal with colors » using said command.

How to customize the Neofetch of our GNU/Linux Distro?

How to customize the Neofetch of our GNU/Linux Distro?

But, before starting this post about this striking and fun customization trick for your «Prompt (PS1) from the Linux Terminal», we recommend you explore a previous related post with this scope, at the end of reading it:

How to customize the Neofetch of our GNU/Linux Distro?
Related article:
How to customize the Neofetch of our GNU/Linux Distro?

Beautify the Prompt (PS1) of your Linux Terminal with lolcat

Beautify the Prompt (PS1) of your Linux Terminal with lolcat

Steps to customize the Prompt (PS1) of the Linux Terminal with colors

To start and successfully achieve this procedure, and avoid future problems, as a pertinent good computer practice, the first thing we will recommend is, the «back up our current .bashrc file». That is, the basic configuration file of our current user's Bash environment in the GNU/Linux operating system that we are using. To do this, you can use both the Terminal and your preferred File Explorer to make a copy of it.

Once the relevant backup has been made, we can continue with the next steps without fear of damaging something and not being able to resolve it or return to the starting point.

  • Edit our current “.bashrc file”: Let's remember that we can use either a CLI Editor like Nano or Vi, or a GUI Editor like Gedit or Mousepad. And that said file is located in the path /home/$USER/.bashrc.
  • Disable the current prompt (PS1): Once our basic configurations file of the personal Bash environment is open, we must comment on the current line of the prompt (PS1) that we have in operation. To do this, it will only be enough to put the numeral symbol at the beginning of it: “#”.
  • Insert new prompt configuration lines (PS1): To do this, we will have to copy, paste and the following lines offered in our open file, and right at the end of the disabled final line of the previous prompt (PS1):
Texto=$((echo "Bienvenido al prompt del sistema $USER@$HOSTNAME a las `date +"%D"-"%T"`") | lolcat -f -F 0.7 -S $LOLCAT_SEED 2>/dev/null)
PS1="\[\e[33;1m\]┌─────(\[\e[34;1m\] `(echo $Texto)` { \[\e[31;1m\]\w\[\e[33;1m\] }\n└──┤ \[\e[32m\]\$ "

Once these steps are done, you will only need to open a Linux Terminal (Console) and test that the changes have been satisfactory, or that they issue an error message that must be corrected.

Screen shots

And for a better understanding of everything previously explained, we leave you the usual related screenshots:

Screenshot 01

Screenshot 02

Screenshot 03

How to customize the logo of our Distro when running Neofetch?
Related article:
How to customize the logo of our Distro when running Neofetch?

Summary 2023 - 2024

Summary

In short, we hope that this latest customization trick taught will allow many, especially on Desktop days, the power «show your Linux Terminal Prompt (PS1) with colors» using the well-known “lolcat” command. And since, surely As a good Linux user you will already have your Prompt (PS1) customized through great tricks (configurations and optimizations) applied to your .bashrc file, we invite you to tell us about them for the knowledge and benefit of the entire Community, which loves to apply these customizations.

Lastly, remember to share this useful and fun post with others, and visit the beginning of our «site» in Spanish or other languages (adding 2 letters to the end of the URL, for example: ar, de, en, fr, ja, pt and ru, among many others). Additionally, we invite you to join our Official Telegram channel to read and share more news, guides and tutorials from our website. And also, the next Alternative Telegram channel to learn more about the Linuxverse in general.


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.