1. Home
  2. Linux
  3. Customize the linux terminal

How To Customize The Linux Terminal

The Bash shell is a tool everyone has used at least once. Both advanced users and those that are just starting out, Bash is a must-know tool on Linux.  Despite the fact that so many users interact with the Bash shell on Linux (and even on other operating systems like Mac), the shell has largely stayed the same; plain and ugly. To be fair, Bash developers are more worried about the way their shell functions. They aren’t spending their days working on making a pretty command interface, with nice prompts, GitHub integration, and etc. That’s why in this tutorial, we’ll teach you how to customize the Linux terminal and  make it look much, much more modern. We’ll go over installing everything from, themes, to useful additions that make using the Bash prompt easier to use.

Bash-It

The best and easiest way to improve the Bash shell is with the Bash-It framework. To put things simply: it’s a collection of scripts and tools specifically created to add things into Bash.

Bash, on it’s own is very dated and could use minor improvements — especially in the looks department. To get this framework running, the best way is to install the code directly from Github. Packages exist here and there to get the tool installed on several different Linux distributions, but for the most part they really aren’t needed. Mostly because nothing is being compiled and it’s just files that are moving around.

Installation

As mentioned before, the Bash-It framework requires the Git package for installation to work. Follow the instructions to get Git running on your system:

Ubuntu

sudo apt install git

Debian

sudo apt-get install git

Arch Linux

sudo pacman -S git

Fedora

sudo dnf install git

Open SUSE

sudo zypper install git

Other

Git is very well known. Even if your operating system isn’t in the list above, chances are very good that you’ll still be able to install it. Just open a terminal, and use your distribution’s package manager to search for “git”.

Once Git is installed, start the Bash-It installation process:

git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it

We’ve got the code locally, and it is easily installed. There’s no need to grab any other files but everything isn’t done. The install.sh file needs to run, so that Bash-It can take the default Bash profile and make a backup (that way if anything bad happens, the user can restore the backup and start over).

Run the post-install script as a regular user. Do not run as root. Doing so will replace your user’s Bashrc/Bash_profile.

sh ~/.bash_it/install.sh

Running the script like this is good. It’ll go through and back up everything. However, if you’re interested in using some plugins, such as aliases and etc, run the post-installation script with this instead:

~/.bash_it/install.sh --interactive

After running this script, the Bash-It framework is up and running on the system. Update it, by going to the terminal and using this command:

bash-it update

Bash-It themes

Many different themes for the terminal come with the Bash-It framework. These themes are all installed locally, all s user needs to do is change a single line in ~/.bash_profile

To list all installed themes, first CD to the theme directory.

cd ~/.bash_it/themes/

To show all available themes, do:

ls

This will print out a list of all the themes in the theme directory. From here, find the name of a theme to try out.

Activate any theme by editing ~/.bashrc:

nano ~/.bashrc

Find the line: export BASH_IT_THEME=, and replace the text in between the two quotes to tell the framework to use a new theme. Press Ctrl + O to save.

To see the new theme active, close all terminal windows and re-open them.

Creating your own Bash prompt with EZ Prompt

Don’t want to use the Bash-It framework but still want a custom prompt? Check out EZ Prompt instead. It’s a web tool that allows anyone to tinker around, and make a custom, beautiful Bash prompt.

The best part of EZ Prompt, is that it supports things like status elements, extra characters, allows users to re-arrange how the Bash shell presents elements, and even allows for custom color options too!

When you’ve generated your own prompt, edit your ~/.bashrc:

nano ~/.bashrc

Inside of the Nano text editor, simply paste the newly generated code and be on your way.

Powerline-Shell

For those that want a beautiful terminal, but don’t want to spend time configuring a framework, or messing with a custom prompt generator, there is Powerline-Shell.

It’s a powerline style terminal theme that works with Bash and other Bash alternative shells. To install powerline shell, first clone the source from GitHub.

git clone https://github.com/milkbikis/powerline-shell

Then, cd into the source code directory.

cd powerline-shell

Rename the config.py.dist file to config.py.

mv config.py.dist config.py

With all the files downloaded and set up correctly, the installation is ready to begin. Run the installation with:

./install.py

The installation may take a couple of seconds to install, but it’s not a long process. When everything is on the system, all that’s left is to set up ~/.bashrc.

Run the nano text editor and open the bashrc file.

nano ~/.bashrc

With the Bashrc file open, paste the following code:

function _update_ps1() {
PS1="$(~/powerline-shell.py $? 2> /dev/null)"
}

if [ "$TERM" != "linux" ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

Save Nano with Ctrl + O. To see the new powerline-shell in action, close all running terminal windows and re-open them.

Note: Powerline-shell runs with Python. For the most part, all Linux distributions ship with the latest version of it. So Powerline-shell will run just fine. However, some only use older versions of Python (like 2.6).

In order for Powerline-shell to work, install the argparse package. This will ensure that it plays nice with Python 2.6

pip install argparse

Conclusion

Bash is a useful tool, and on Linux it’s an essential tool for users to know. You can write Bash scripts to automate Linux. In fact, Bash is so popular, it’s been added to Windows 10. Having a plain looking Bash prompt isn’t the end of the world; it’s just a terminal interface after all. However, it’s much easier to fall in . ve with the terminal if it’s easy on the eyes.