Custom ASCII art and random one-liner welcome messages on Linux Terminal start-up

Would it not be cool if your terminal welcomes you with an ASCII art and a random one-liner each time you start it up!

Like this:-

Custom welcome to terminal

Remember to like my post and star my GitHub repository if this post helps you!

Linux users (Sorry Mac owners (for the time being, use the custom method after this)) can simply install my poketerm pip package!

Remember to install with sudo permissions!

$ sudo pip install poketerm
$ poketerm -t 1
$ poketerm -h

You can customise the above according to your need or you can save yourself some trouble and use my code on github which does everything that I am going to describe below.

Firstly download and put this file in your /home/$USER/ folder.

All you need to do now is manipulate the .bashrc shell script that Bash(Terminal) runs whenever it is started interactively. You can put any command in that file that you could type at the command prompt and they will run whenever you start Bash.

Note: The following makes changes to default terminal Bash. If you are using some other shell you will have to make changes to their respective analogous file.

NOTE FOR MAC USERS: The .bashrc equivalent of Mac is .bash_profile, Mac users may use that file for the following changes.

After opening this file with your favourite editor with a command like

vim ~/.bashrc

You will find the line containing the following in the start:

#!/bin/bash

Just after which you will have to add this small piece of code that I wrote:

echo "Welcome $USER "
echo "|\_                  _"
echo " \ \               _/_|"
echo "  \ \_          __/ /"
echo "   \  \________/   /"
echo "    |              |"
echo "    /              |"
echo "   |   0       0   |"
echo "   |       _       |"
echo "   |()    __    () |"
echo "    \    (__)      |"
file="/home/$USER/fortunes.txt"
if [ -f "$file" ]
then
    shuf -n 1 $file
fi

The file should look similar to this now:

.bashrc code after addition of lines

Save it and you are good to go!

Most of the above code is self explanatory. The only thing that you might not get is the statement inside the if conditional. If the file exists, then a random line is returned out of the 10,000 lines in the fortunes.txt file.

What more can you do?

You can create your own custom ASCII art or you could find some here. Just format it and replace it with my noobish art. Do keep in mind to not use art which is very large in line length/height else it might not appear as intended. Also keep in mind the characters that are used in the art. Test the piece of code as a separate shell script before you add it to the file. You can also save the art in a file/folder and invoke one randomly just like the one-liner.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s