Tuesday, September 15, 2015

Colorful Linux Terminal

Lolcat – A Command Line Tool to Output Rainbow Of Colors in Linux Terminal

> For those who believe that Linux Command Line is boring and there isn’t any fun, then you’re wrong here are the articles on Linux, that shows how funny and naughty is Linux..

>Here in this article, I will be discussing about a small utility called “lolcat” – Which produce rainbow of colors in  terminal.

>What is lolcat?

> Lolcat is an utility for Linux, BSD and OSX which concatenates like similar to cat command and adds rainbow  coloring to it. Lolcat is primarily used for rainbow coloring of text in Linux Terminal.
Installation of Lolcat in Linux

1.  Lolcat utility is available in the repository of lots of Linux distributions, but the available version bit older. Alternatively you can download and install latest version of lolcat from git repository.

>Lolcat is a ruby gem hence it is essential to have latest version of RUBY installed on your system.

#yum install ruby*

#yum install  rubygem*

> Once ruby package has been installed, make sure to verify the version of ruby installed.

# ruby --version

2.  Next download and install the most recent version of lolcat from the git repository using following commands.

a. # wget    https://github.com/busyloop/lolcat/archive/master.zip

b. # unzip master.zip

c. # cd lolcat-master/bin

d. # gem install lolcat

> Once lolcat is installed, you can check the version.

# lolcat --version

Usage of Lolcat

3. Before starting usage of lolcat, make sure to know the available options and help using following command.

# lolcat -h

4. Next, pipeline lolcat with commands say ps, date and cal as:

Ex. #Command  | lolcat

# ps    | lolcat
# date | lolcat
# cal | lolcat
# netstat -ant |lolcat
# ss a- |lolcat

5. 3. Use lolcat to display codes of a script file as:

# lolcat  service.sh

6. Pipeline lolcat with figlet command. Figlet is a utility which displays large characters made up of ordinary screen characters. We can pipeline the output of figlet with lolcat to make the output colorful as:

# echo I * Tecmint | lolcat

# figlet I Love Tecmint | lolcat

Note: Not to mention that * is an unicode character and to install figlet you have to yum and apt to get the required  packages as:

# yum install figlet

7. Animate a text in rainbow of colors, as:

$ echo I * Tecmit | lolcat -a -d 500

> Where -a =  --animate, -a:   Enable psychedelics
> Where -d = --duration, -d :   Animation duration (default: 12)
> Where -s =  --speed, -s :   Animation speed (default: 20.0)

Ex :  # echo SHANKAR DEO | lolcat -a -d  500 -s  50

>Here the option -a is for Animation and -d is for duration. In the above example duration count is 500.

8. Read a man page (say man ls) in rainbow of colors as:

 # man ls   | lolcat

Note: You can use lolcat with any other command in pipeline and get colored output in terminal.

9. You may create alias for the most frequently used commands to get command output in rainbow of colors. You can alias ‘ls -l‘ command which is used for long list the contents of directory as below.

# alias lolls="ls -l | lolcat"
# lolls

> You may create alias for any command as suggested above. To create permanent alias, you have to add the relevant code (above code for ls -l alias) to ~/.bashrc file and also make sure to logout and login back for the changes to be taken into effect.

10.Command: Cowsay

An ASCII cow in terminal that will say what ever you want. Install Cowsay

root@tecmint:~# apt-get install cowsay (for Debian based OS)
root@tecmint:~# yum install cowsay (for Red Hat based OS)

# cowsay I Love nix

## cowsay I Love nix |lolcat   (for color full cow)

11. Command: cmatrix

You might have seen Hollywood movie ‘matrix‘ and would be fascinated with power, Neo was provided with, to see anything and everything in matrix or you might think of an animation that looks alike Hacker‘s desktop.

Install cmatrix
**************
# yum install cmatrix

#cmatrix

----------------------------------------------------------------------------------------------------------------------

1 comment: