Skip to main content

Rainbow Text, ASCII Art and More: Customize Your Linux Terminal

Linux Tools
(Image credit: Tom's Hardware)

The Linux terminal, sometimes referred to as the command line or the “shell” is a simple yet powerful way to interact with the computer. Commands are typed into the terminal, and their output is displayed immediately to the terminal. 

From the Linux terminal we can create users, make network connections and download files. Despite all of this power, the terminal is not as “friendly” as a modern desktop. How can the terminal be made a little friendlier?  By customizing the Linux terminal with rainbows, art and handy information such as CPU temperature, IP address and the latest weather.

(Image credit: Tom's Hardware)

This tutorial will work with the vast majority of Linux distributions. We tested using Ubuntu 20.04 and it will also work with all models of Raspberry Pi running Raspberry Pi OS. 

Customizing the Linux Terminal with bashrc 

(Image credit: Tom's Hardware)

The .bashrc file is located in your home directory and it is used to configure the Bash prompt. Every time a new Bash shell is launched, including any remote connections, the bashrc file is used to configure the shell as per our requirements. Typically we leave the bashrc file as is, but using a few extra tools the shell can report CPU temperature, IP address and the latest weather report.

To edit bashrc

1. Open a terminal and install Geany. Geany is pre-installed on Raspberry Pi OS.

sudo apt install geany

2. Open Geany, found in the Programming menu.

3. Click on File >> Open and navigate to the Home directory.

4. Right click and select “Show Hidden Files” and look for .bashrc.

5. Go to the bottom of .bashrc and create a comment, a line that starts with #. 

# Tom’s Hardware Hacks

Adding the latest weather to your Linux Terminal 

(Image credit: Tom's Hardware)

The latest weather direct to your terminal, handy if you are in the data center, or stuck in a windowless office. For this wttr, a simple text based service is used. 

In the bashrc file

1. Go to the bottom of the file, underneath the comment line.

(Image credit: Tom's Hardware)

2. Add these lines, change the CITY to match where you live. The ?A option ignores any user agents and forces ANSI output. The ?u option forces Fahrenheit temperatures. 

#Weather
curl wttr\.in/"CITY"?0?A?u

Linux Tools

(Image credit: Tom's Hardware)

3.  Save the code and open a new terminal, you will now see the latest weather details for your city. 

Add Bold ASCII Art to Your Linux Terminal 

(Image credit: Tom's Hardware)

The American Standard Code for Information Interchange (ASCII) is a common encoding standard for sharing electronic information. ASCII can be used to create simplistic graphics in the terminal. The figlet tool is used to create large ASCII text banners and it is simple to install.

1. Open a terminal and install using this command.

sudo apt install figlet

2.  Type this command to test that figlet has been installed correctly. 

figlet “Hello World”

Linux Tools

(Image credit: Tom's Hardware)

3.  To add a custom banner for the weather data in bashrc, go back to the bashrc file and insert a line below #Weather. 

Linux Tools

(Image credit: Tom's Hardware)

Show the current CPU temperature 

(Image credit: Tom's Hardware)

In Linux, CPU Temperature data is collected using a tool called lm-sensors which will read the sensors present in the CPU and other devices and show the data in the terminal. The Raspberry Pi has a command, vcgencmd which can be used to measure the CPU temperature. Here are both ways to get the temperature for your chosen machine.

Ubuntu / Linux Users

1. Install lm-sensors via the terminal

sudo apt install lm-sensors

2.  In the .bashrc file add a new line and use figlet to create a heading for the CPU temperature section. 

figlet “CPU Temp”

3.  Add a new line which will run the sensors command, then pipe the output of that command through a series of searches and cuts to strip out just the CPU temperature. 

sensors | grep -A 0 '+' | cut -c1-25 | grep "Package id 0:" | cut -c17-23

4.  Open a new terminal and you will see the current CPU temperature.

Raspberry Pi

(Image credit: Tom's Hardware)

1.  Create a variable called “data”  which will store the output of the command. But before that happens the output of the command is piped using “|” to be the input of the next command, “cut” which slices just the temperature from the output. 

data=$(vcgencmd measure_temp | cut -d '=' -f 2)

2.  Use figlet to print the data to the screen. 

figlet "CPU Temp: ""${data}"

Linux Tools

(Image credit: Tom's Hardware)

3.  Save the file and then open a new terminal to see the output. 

Show your IP address in Linux Terminal 

(Image credit: Tom's Hardware)

One piece of information that is often needed is the internal IP address and by following these steps this will be displayed when opening a terminal.

1. At the bottom of the bashrc file add two lines, a comment to identify what the code will do, and the hostname command which will pipe into the figlet command.

#Internal IP Address
hostname -I | figlet

Linux Tools

(Image credit: Tom's Hardware)

2.  Save the file and open a new terminal to see the IP address. 

Make a rainbow! 

(Image credit: Tom's Hardware)

The standard output of the Bash shell is functional, but not colorful. But fear not as color is just a few steps away. Lolcat is a command that will add a colorful rainbow effect to any standard output.

1. Open a terminal and install lolcat.

sudo apt install lolcat

2.  Open bashrc and edit the figlet lines for weather, CPU temperature and IP address so that the command uses a pipe to send the output to lolcat. 

figlet "Weather" | lolcat
figlet "CPU Temp: ""${data}" | lolcat
hostname -I | figlet | lolcat

3.  Ubuntu users will need to format their CPU temperature section with lolcat as follows. 

sensors | grep -A 0 '+' | cut -c1-25 | grep "Package id 0:" | cut -c17-23 | lolcat

Make your Bash prompt unique 

(Image credit: Tom's Hardware)

The Bash prompt is where commands are entered, and it can also be used to display simple information. By default it shows the username, hostname and current working directory.

1. At the end of the bashrc file add a comment to explain what the next section of code will do.

#Cool Bash Prompt

2.  Create three variables to represent the colors, red, green and blue. For each variable the tput command will be used to set a specific color for the text in the prompt. 

red=$(tput setaf 1)
green=$(tput setaf 2)
blue=$(tput setaf 6)

3.  Add an additional line will handle resetting the colors back to normal. 

reset=$(tput sgr0)

4.  This line of code will create a new prompt. The first section, time (\t) and username (\u) will be red. The “@”symbol will be white, the hostname (\h) is green, working directory (\w) will be cyan. Finally the $ (denoting a user with no special powers) will be reset to white.

export PS1='$red\]\t $red\]\u\[$reset\]@\[$green\]\h\[$reset\]:\[$blue\]\w\[$reset\]\\$ '

(Image credit: Tom's Hardware)

Complete Code Listing for Customizing Linux Terminal 

Ubuntu / Linux 

(Image credit: Tom's Hardware)
#Tom's Hardware Hacks
#Weather
figlet "Weather" | lolcat
curl wttr\.in/"New York"?0?A?u

#CPU Temp
figlet "CPU Temp" | lolcat
sensors | grep -A 0 '+' | cut -c1-25 | grep "Package id 0:" | cut -c17-23

#Internal IP Address
hostname -I | figlet | lolcat

#Cool Bash Prompt
red=$(tput setaf 1)
green=$(tput setaf 2)
blue=$(tput setaf 6)
reset=$(tput sgr0)
export PS1='$red\]\t $red\]\u\[$reset\]@\[$green\]\h\[$reset\]:\[$blue\]\w\[$reset\]\\$ '

(Image credit: Tom's Hardware)

The end of the bashrc file should now look like this. 

# Tom's Hardware Hacks
#Weather
figlet "Weather" | lolcat
curl wttr\.in/"New York"?0?A?u
#figlet "CPU Temp"
data=$(vcgencmd measure_temp | cut -d '=' -f 2)
figlet "CPU Temp: ""${data}" | lolcat
#Internal IP Address
hostname -I | figlet | lolcat

#Cool Bash Prompt
red=$(tput setaf 1)
green=$(tput setaf 2)
blue=$(tput setaf 6)
reset=$(tput sgr0)
export PS1='$red\]\t $red\]\u\[$reset\]@\[$green\]\h\[$reset\]:\[$blue\]\w\[$reset\]\\$ '

Change the look and feel of the terminal 

Ubuntu / Linux

In the Ubuntu terminal, the Preferences menu is found in the “hamburger” menu in the top right of the window. Create a new Profile by clicking on the + sign and give the profile a name.

(Image credit: Tom's Hardware)

The font, background and foreground colors can be changed via the Colours tab. The transparency of the window can also be altered here. 

(Image credit: Tom's Hardware)

 Raspberry Pi

(Image credit: Tom's Hardware)

The default terminal can be customized to use different fonts, and colors.

1. Click Edit >> Preferences.

2. Click on Terminal Font and change the font style and size to meet your preferences.

(Image credit: Tom's Hardware)

3.  Click Select and then Ok to make the change. Note that some fonts and sizes are easier to read than others. 

(Image credit: Tom's Hardware)
  • mamasan2000
    There is also Fish shell.
    https://fishshell.comhttps://github.com/fish-shell/fish-shellAnd when you have that installed, you can choose how you want the prompt to look like with Oh My Fish
    https://ostechnix.com/oh-fish-make-shell-beautiful/
    Functionality paired with beauty.
    Reply
  • quintux
    sorry to say but this is pointless. the only hack i want in my terminal is better, more legible fonts.
    Reply
  • TechLurker
    This brings back memories when you were considered pro level to use the rainbow font in Runescape and MySpace.
    Reply