My Linux terminal color scheme
The Linux terminal color scheme is not always attractive. Often is is just black and white. You will learn how to create a nice Linux terminal color scheme that is pleasant and easy to read.
In this post, you will learn how to add some colors to your terminal which is black and white by default in some distros such as Arch Linux. It is not pleasant to the eye especially to newcomers. It may not seem important, but adding some color to the terminal can greatly improve the user experience.
I will use Arch Linux as an example, and I will apply a color scheme in Bash environment, Pacman (the Arch Linux package manager), and Nano text editor. All settings except Pacman, should work in other Linux distros.
So, let’s start to add a Linux terminal color scheme. As usual, you can follow the video tutorial or continue reading below.
1. Enable colors in Bash
What is Bash?
Most of Linux distros use Bash shell, which stands for Bourne-again shell. The interface you see in the terminal is called Shell environment.
So, when I talk about making terminal colorful, I mean enabling colors in Bash.
By default, you Bash environment does not have any color. Everything is just black and white.
Bash settings files
To make your Bash colorful in Arch Linux, you need to edit Bash setting files. There are two files you can edit. One is located in /etc/bash.bashrc
, another is ~/.bashrc
in your home folder. The file /etc/bash.bashrc
defines the system-wide settings for all users and your root account, while ~/.bashrc
is user specific. So, if you have several users, you need to edit this user specific file for every user. Also, if you edit .bashrc
in your home, its setting will be prioritized over /etc/bash.bashrc
.
I recommend you to edit only .bashrc
. It is safer. But if you are a confident user, edit /etc/bash.bashrc
, this will apply the settings system-wide and save your time in the future if you create several users.
Make a backup copy of the settings file:
cp .bashrc .bashrc.backup
For system-wide bashrc:
sudo cp /etc/bash.bashrc /etc/bash.bashrc.backup
Note: Regardless of which file you decide to edit, always it is a good idea back up the original file.
Now, it is safe to edit any of these files. So, If something goes wrong, you can simply restore the backup file.
Adding my Linux terminal color scheme
Normally, you would have to go through all the wiki pages of Arch Linux and configure your preferences.
But you are lucky because I have done all that job already. You just need to download bash.bashrc, DIR_COLORS and .bashrc and move these files to the following places.
The bash.bashrc
file to /etc/bash.bashrc
sudo mv bash.bashrc /etc/bash.bashrc
The DIR_COLORS
file move it to /etc.
sudo mv DIR_COLORS /etc/
Now, move .bashrc
file to your home directory.
mv .bashrc ~/.bashrc
Then, restart the terminal and that is is. Now you have some color in your terminal.
2. Colorful output in Pacman
If you use Arch Linux, you can enable syntax highlighting for pacman
. Its output is of the same color by default and it will be easier to read it when it is colorful.
As always, first back up your pacman.config
file.
cp /etc/pacman.conf /etc/pacman.conf.backup
And uncomment the word color in that file. The fastest way to do that is to run this command:
sed -i 's/#Color/Color/g' /etc/pacman.conf
So, run the pacman update again.
sudo pacman -Suy
Now, there is some color differentiation in the output.
When you open the manual of pacman
, there is some syntax highlighting as well. It is much easier to read.
As I said before these are small changes but they make the terminal look more pleasant.
3. Syntax highlighting in Nano
Nano is a text editor in the terminal. Usually it does not have text highlighting by default. If you use the Nano text editor, as I do, you will benefit from enabling syntax highlighting in it.
For example, when you open, let say awk
script, there is no syntax highlighting and this is how it looks.
Let is enable syntax highlighting.
First, backup your nano config file. If something goes wrong, you will just have to restore the backup.
sudo cp /etc/nanorc /etc/nanorc.backup
Next, activate color mode predefined in the files /usr/share/nano/*.nanorc
.
To enable these settings, you have to edit one of these ~/.nanorc
or /etc/nanorc
files. You already know the difference between those two files nanorc
file is for user-specific, whereas /etc/nanorc
is for system-wide settings. I will edit the system-wide settings.
Open the file.
sudo nano /etc/nanorc
And paste the following line in the end of the file.
include "/usr/share/nano/*.nanorc"
Press Ctrl+O to write the changes, and Ctrl+X to exit Nano.
Now, if open the awk
script again, you will see some color.
Is not it better now?
Conclusion
Enabling the Linux terminal color scheme is a small thing to do but it will make your terminal more enjoyable to use.
Please, let me know on the comments section if you know more Linux terminal color schemes. Maybe I missed something.
Comments
Haseeb Ul Hassan
Hello, after going throug these steps, the colors are not changed in CentOS 7 and it seems like that my username@hostname is replace by bash4.2 $ please help me to restore to older condition or to correct)
Sakisho
Where is the download section to get those three files?
Average Linux User
Probably, you missed it:
FLAVIO FERNANDES FRANCO FILHO
Hi, average. I liked this color scheme showed in this article, except in one dot: The strong background green when show directories. How I change for the another color?
Average Linux User
That green background indicates that a directory is writable by others. I would better keep this setting.
If you still want to change it, search how to edit
$LS_COLORS
.Ravi
jabardast bro, in lock-down maja aa gya he he he i mean you are rocking…………….!
Average Linux User
Thank you 😄
Loyalty
Thanks! But the file .bashrc is not included in the zip folder
Average Linux User
It is included! Please, enable show hidden files in your file manger or use the terminal:
MIlan
Dear! Is it possible in Linux Debian 10.3 Buster to make a Terminal color scheme using the Bash command?
Thank you!
skznow
Thank you.
Prathamesh Pratap Kinare
Hi Thanks for useful content! but post replacing bash.bashrc i am not able to see user@hostname> in terminal. its now replaced with bash-4.2$
How to get back to previous one ?
kindly revert , Awaiting for your response. linux version Rehl 7.6
Shane Baker
This is great, many thanks. One thing I noticed about the syntax highlighting in nanorc is that if an apostrophe appears in a line commented with # the text afterwards appears in orange until another apostrophe appears. Is it not possible to have all the text after # on a line appear in green?
Average Linux User
You can active it by removing the Strings colors. For example, for sh scripts, edit the file
/usr/share/nano/sh.nanorc
by commenting out Strings as below:But keep in mind it will remove yellow color from all quoted strings. For more flexible configuration, you need to use more advanced regular expressions.
Tushar Goyal
Please make a proper customization of theme video for Ubuntu 18.04 LTS
Average Linux User
How about this http://averagelinuxuser.com/customize-ubuntu-18-04/
ElDee
Thank you. Very nice! This works very well with Sakura terminal emulator using the Xterm palette.
Average Linux User
Hi ElDee, Thank you for the comment and sharing your experience. Sakura is just a terminal emulator. So, it is still Bash and of course this scheme should work.