Introduction
If you are a Linux user, you will use your terminal a lot. Terminal, once you know how to navigate your machine with it and work on a daily basis, will tremendously increase your productivity. For example, you can easily move files around or use CLIs from your favorite providers or apps to perform complicated tasks that would take way more time if done through a visual interface. In summary, it allows you to have a greater understanding of how your machine works and lets you be more productive, at the cost of you staring at a black screen with cryptic messages.
Just type cmatrix
in it for fun.
Anyway.. Since we are going to spend a lot of time in it doing various complex things and probably get frustrated over time, why not make it pretty and fun. For your own sanity of course.
In this very short tutorial I will show you how to easily customize your terminal. I am myself using Linux Ubuntu 19.10. Users from Mac and Linux distros should have a pretty similar experience. Microsoft users, I can do nothing for you.
Most Ubuntu users start with the terminal looking almost like this:
A completely fine looking terminal if you ask me. But not fancy enough for our special breed of dev. We want something personal so when our colleagues or friends look at our terminal, they understand that we know what we are doing.
Let's change things a bit!
First Steps
The configuration of our terminal is defined by the variable PS1
. To change what your terminal displays, you just need to type in it
export PS1='I am so fancy 😄 $ '
Magic! you now have a custom terminal. But oh misery, when you close and boot it up again, your terminal will be going back to boring old normal. Don't worry, I got you, there is a way of making things more durable.
The secret lies in the
.bashrc
file.
Go ahead and type the following command into your terminal
cd
vim .bashrc
This will open a file looking like this
We know from before that the variable PS1
holds our prompt display. Go to the following line and uncomment
force_color_prompt=yes
then go to the line below
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
Huray! this is your traditional Ubuntu terminal prompt.
Ok, great, we have it.. now what?
Now comes the fun, it is time to customize things a bit. But first, let's understand this mess.
Here is a short description of the different parts
-
${debian_chroot:+($debian_chroot)}
: this part is explained here in a very good way, I encourage you to read it -
\[\033[01;32m\]...\[\033[00m\]
: Are the opening and closing tags of bash text styling -
\u
,\h
and\w
: respectively user, machine name and current path
In order not to get too much content in, we will first just create a simple prompt that will look like this
😍😍 DEV MADE ME DO THIS 😍😍 $
(with more colors)
Let's customize
In your .bashrc go to
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
We will start by removing the unwanted boring content. We will remove the username and machine name but will let the path in. Always nice to know where you are. Your code should look like:
PS1='${debian_chroot:+($debian_chroot)}:\[\033[01;34m\]\w\[\033[00m\]\$ '
to apply the changes, save your current modification and type in your terminal:
source .bashrc
We have to continue the work, enter again in your .bashrc
and change the code to the following:
PS1='${debian_chroot:+($debian_chroot)}😍😍 DEV MADE ME DO IT 😍😍 \[\033[01;34m\]\w\[\033[00m\]\$ '
This is not so bad... right? But we miss something... I know! Colors!
We need to try and make a rainbow. Basically how the styling work is as follows. As seen before, we have \[\033[01;32m\]
as opening tag and \[\033[00m\]
as closing tag.
Adding Colors in your Life
openning
\[\033[01;32m\]
is the bash way of saying increased intensity with color green. In this string of characters, the 01 means increase intensity and the 32 means green. Try 02 instead of 01 and your text will be a bit transparent. Try 33 instead of 32 and your text will become brownish. DON'T FORGET TO SOURCE .BASHRC
.
closing
\[\033[00m\]
really just means no more styling. Yep, that's it.
So! let's finish our beautiful rainbow of colors. We will use the following colors:
red: 91
yellow: 93
green: 92
light blue: 96
blue: 94
purple: 95
which will give us:
PS1='${debian_chroot:+($debian_chroot)}😍😍 \[\033[01;91m\]D\[\033[00m\]\[\033[01;93m\]E\[\033[00m\]\[\033[01;92m\]V\[\033[00m\] \[\033[01;96m\]M\[\033[00m\]\[\033[01;94m\]A\[\033[00m\]\[\033[01;95m\]D\[\033[00m\]\[\033[01;94m\]E\[\033[00m\] \[\033[01;96m\]M\[\033[00m\]\[\033[01;92m\]E\[\033[00m\] \[\033[01;93m\]D\[\033[00m\]\[\033[01;91m\]O\[\033[00m\] \[\033[01;93m\]I\[\033[00m\]\[\033[01;92m\]T\[\033[00m\] 😍😍 \[\033[01;34m\]\w\[\033[00m\]\$ '
Alright... This was of course just to showcase what you could do. I personally went for something more basic:
Congrats! You are now a master of personalizing your command prompt. In order to learn more about how to visually customize your prompt, use the link right below to find more resources. You will be able to create crazy blinking animated terminal sessions with it, trust me it's fun:
It would be nice to see what you guys built, so let us know in the comments!
Til next time.
Mike
About me
I am a partner at MMPG Consulting, a firm active in the custom software development industry in the Spanish and Swiss markets.
For more content, you can add me on LinkedIn or shoot me a DM if you want to discuss specific topics, your software or an idea you want to implement.
Top comments (12)
If you do anything with your terminal, post your pictures, surely we can find something better than my boring one
So much love zsh & powerlevel10k.
How did you put the Manjaro logo right there?
I use Meslo Nerd Font and Type
p10k configure
to configuration.Got a screenshot?
I don't have. But you can follow step with
p10k configure
and choose what you want.With this, I guess :
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon)
Big fan of Hyper terminal and have it matching my favorite VS Code theme Shades of Purple both by
Ahmad Awais ⚡️
MrAhmadAwais ahmadawais https://AhmadAwais.com/
Top half is the customized hyper terminal using WSL /w ZSH & Oh-my-zsh.
ahmadawais / Shades-of-Purple-Hyper
🦄 Shades of Purple — A professional theme with hand-picked & bold shades of purple for Hyper Terminal.
Below is VS Code porting that in as the default terminal, too.
ahmadawais / shades-of-purple-vscode
🦄 Shades of Purple — A professional theme with hand-picked & bold shades of purple to go along with your VSCode. Reviewed by several designers and 75+ theme versions released to keep it updated. One of the top rated best VSCode themes on VS Code Marketplace. Download →
Ouuuh nice! Definitely more furnished than mine! Looks good
Anyone know which terminal customisation this is?
Try ZSH shell with Oh My ZSH plugins and themes
Just a basic setup