How to customize Terminal in Ubuntu
This tutorial will show you how to customize the look and feel of Terminal in Ubuntu. The second part of the article can also be applied to any other distribution.
Terminal in Ubuntu, or in any GNU / Linux distribution, is a very essential tool. Terminals are tools used to control, manipulate and manage the entire system or even a group of systems.
Although it may seem like just a prompt for host-name and user-name, the Terminal interface has been improved over the years and is aesthetically pleasing in most graphic distributions today. Today, Quantrimang.com will explain how users can customize the look and feel of Terminal in the most commonly used distribution, Ubuntu. The last part of this article can also be used in any other distribution.
How to customize Terminal in Ubuntu?
- Use the 'Preferences' option
- 1. Text
- 2. Colors
- 3. Scrolling
- Customize using the .bashrc file
- Edit sections and layout
- More colors
- The part shows the colors
- Edit .bashrc
Use the 'Preferences' option
Ubuntu's terminal has a 'Preferences' option that can be used to customize the Terminal to some degree. This option can be accessed by right clicking on an empty area in Terminal and selecting 'Preferences'.
There are many options listed in many tabs. They have been listed and explained exactly below:
1. Text
Let's explore the basic capabilities of changing the text style in Terminal and a few other options.
- Terminal size (about rows and columns)
- Font and font size
- Space between cells
- Pointer shape and flashing mode
2. Colors
The available changes are:
- Colored themes available
- Default background and foreground (text) colors
- Bold text, cursor, and highlighted text color
- Sliders (slider) throughout
3. Scrolling
The options here are:
- Toggle scroll bar on / off
- Roll based on output (the cursor will go to the bottom if there is a new output)
- Scroll based on pressing a key (the cursor will go to the bottom if any key is pressed)
- Roll limit
Those are all options provided by default for changes in Terminal.
Customize using the .bashrc file
Edit sections and layout
Every Linux distribution has a custom Bash profile file in the Home directory. It can be used (very widely) to change the appearance and function of the command prompt. The prompt is the section that appears after the user logs in to the user account. The default Ubuntu prompt looks like this:
The first part is the username, followed by the symbol '@' and host-name (the name of the system / server). Then there is the location of the working directory and finally the '$' sign , indicating that it is not the root user. Instead, the root user has the '#' symbol .
In a nutshell, the default prompt looks like the following:
user@system-name:working_directory$
This prompt is indicated by the name 'PS1'. The Bash profile file can be used to customize the PS1 prompt in several ways.
The default prompt looks like this:
u@h:w$
It is explained as follows:
- u: User name of the user
- @ : Icon @
- h: Host-name of the system
- ':': Icon ':'
- w: The path of the working directory
- $: The '$' symbol.
All of the above creates the default prompt layout. Now, some other options are as follows:
- d: Date in the format 'Day / month / day' (example: Tue October 1).
- t: Time in HH: MM: SS format.
- n: A new line (go to the next line)
A wider list is available here:
https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Controlling-the-Prompt
Now that you've learned a little more and can practice trying these. However, to be safe, save the current format with this command:
DEFAULT=$PS1
The above command stores the current format of PS1 in variable 'DEFAULT' . Now, if I wanted to try making the username appear in the prompt, what would it look like? According to the code, it is just 'u'. Therefore, you must enter the following command:
PS1="u$ "
'$' is essential and serves as a boundary. The expected results are shown as follows:
You can even add Bash commands to display in the prompt. That can be done in the following way:
PS1="[`uname -sr`] u$ "
The command used, which is uname -sr
, exports the Linux Kernel version. Similarly, you can use many other commands. You can also add simple text like this:
PS1="(Phần văn bản mẫu) u$ "
You can now return to the original layout using:
PS1=$DEFAULT
More colors
Now, you can move on to the more difficult things, which are the actual .bashrc file. If the PS1 variable is set there, it should look like this:
[3[01;32m]u@h[3[00m]:[3[01;34m]w[3[00m]$
Don't worry, this is also quite simple. You can see right away that there is a pattern here. Open with " [" and close with " ]" . Also, there is always a '033' before the sequence of numbers and other symbols. So what do they mean?
"[" and "]" indicate that the characters included are nonprinted characters and represent some of the text's formatting. It applies up to another format bracket, like itself or to the entire following (if no other format is applied).
'033' denotes the color formatting and appearance of the text.
The part shows the colors
The parts shown in color are the numbers ending in 'm'. So 'xxm' will indicate a color. Some standard colors are:
- 30: Black
- 31: Red
- 32: Green
- 34: Blue
- 37: White
- 35: Purple
- 33: Gold
A more detailed list can be found easily.
The article mentions almost everything, the rest are just numbers before the semicolon that some colors have. They represent specific text formats, such as bolded text, underlining, etc. Some code includes:
- 0 : Normal text
- 1 : The text is in bold
- 4 : Underlined text
- 2 : Translucent text
- 8 : Hidden text
Finally, try to create a username, which is red and in bold. The command will look like this:
PS1="[3[1;31m]u$ "
Let's parse this one last time:
- [: Open format brackets
- 033: Indicates that this will format the text color.
- [first; 31m : Indicates that the text must be in bold and red.
- ]: Close the format braces
- u: Get a username
NOTE : Please keep in mind that square brackets opened after '033' are not allowed to close.
Now for the final part, manipulate everything you've learned to create the perfect PS1 format for yourself and add it permanently in the following way:
nano ~/.bashrc
Go to the end of the file and enter the desired PS1 format.
Edit .bashrc
Press CTRL
+ X
Press Y.
Then press Enter
to save the file.
Above is (almost) everything you need to know about customizing Terminal. The latter part of the article can go much deeper, but is still kept in a limit so that users are not confused. Hope you like this article!
Hope you are succesful.
You should read it
- How to install Hyper Terminal in Ubuntu 20.04
- How to Open a Terminal Window in Ubuntu
- Fix Ubuntu unable to open Terminal error
- 3 ways to listen to the radio via Ubuntu Terminal
- How to customize Windows Terminal application
- How to Install and Uninstall Applications from Terminal in Ubuntu
- 6 interesting terminal commands on Mac
- How to Install Custom Fonts in Ubuntu
- How to Install HandBrake on Ubuntu 14.04
- How to spell check in Linux Terminal
- Top 7 best Linux terminal emulators
- How to Install Ubuntu Tweak 0.5.1 in Ubuntu
Maybe you are interested
10 Free AI Tools to Generate Images from Text
How to restore the old context menu in Windows 11
WinRAR 6.10 beta update fixes Windows 11 context menu bug
How to share text on Chrome as a link
How to Justify Text in Cells on Excel - Adjust Text Spacing
How to strikethrough text in Word, write strikethrough text in Word and Excel