Whenever I press Ctrl+J
to open a terminal in my VS Code, I have always wondered how cool it would be if there was a little animation with a clean little welcome message. Then something popped up in my mind and I thought how about we edit the startup file with some of our own custom code in it?
But before we move on to all of that we need to install a few tools:
Figlet - FIGlet is a program for making large letters out of ordinary text and we will be using it as our skeletal tool.
Lolcat - Lolcat is essentially a very handy tool to colorize our skeletal text into a rainbow-themed text
Now, to install them -> Go to your zsh terminal and do the following:
sudo apt-get install figlet
git clone https://github.com/busyloop/lolcat
sudo apt-get install rubygems
-> Rubygems is a package manager for Ruby programsgem install lolcat
We have now installed both Figlet as well as Lolcat. Now we need to install different Figlet fonts for more customization. But first we need to go to usr/share directory which can be done like this:
cd /usr/share
The commands below help in installing the new figlet fonts:
git clone https://github.com/xero/figlet-fonts
-> If permission denied, prepend the command with sudo ->sudo git clone https://github.com/xero/figlet-fonts
Now we need to move the newly installed fonts into Figlet context which can be done like so:
mv figlet-fonts/* figlet && rm –rf figlet-fonts
There is something called zshrc file and It's basically a script that is run whenever you start zsh. We can add some code in this script which will run everytime the terminal opens up.
We can open this up using the following command:
<your-favourite-text-editor> ~/.zshrc
-> Here we need to choose the text editor of our choice. I'm a fan of nano so we can have it like so ->nano ~/.zshrc
Now comes the actual coding part. Trust me it's a bite-sized code that is really simple and let me walk you through it.
Go to the bottom of the file
In a new line -> type
clear
Move to the next line
Type
figlet -f fontname "yourtexthere" -c | lolcat -a -d 1
-> Now what this means is that Figlet will use the font name you provided and -c centers the output horizontally. Further, the -a and -d gives a cool little animation upon terminal bootup for a second.
P.S. I'm using the "Bloody" fontname.
Now, Save your file, Go ahead and restart your terminal. Boom! We have a cool little animation popping up which reads a welcome message every time we start our terminal.
Now that we got it working lets talk about whats happening under the hood, We have a zshrc file which is kind of a middleware layer which runs whenever your terminal boots up or your interactive shell boots up.