How to install Lolcat Tool - generate rainbow colors

To install a Command Line Tool to Output Rainbow of Colors in Linux Terminal &ndash Lolcat

Lolcat

Lolcat is an utility used for rainbow coloring of text in your linux terminal. It can be used for BSD, OSX and Linux, which is quiet similar to the cat command. This tutorial explains the installation procedure of lolcat.

To install Lolcat in Linux

Lolcat belongs to ruby gem package and it is necessary that you possess the latest version of it in your system and install it.

On DNF based Systems

# dnf install ruby

On Yum based Systems

# yum install ruby

On APT based Systems

Run the apt-get command to install the ruby in the system.

root@linuxhelp:/home/user1# apt-get install ruby 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libjs-jquery libruby2.1 libyaml-0-2 ruby2.1 rubygems-integration
Suggested packages:
  javascript-common ri ruby-dev bundler
.
.
.
Setting up rubygems-integration (1.9) ...
Setting up libruby2.1:amd64 (2.1.5-4ubuntu1) ...
Setting up ruby2.1 (2.1.5-4ubuntu1) ...
Setting up ruby (1:2.1.5.1ubuntu1) ...
Processing triggers for libc-bin (2.21-0ubuntu4.1) ...

To check the version of ruby

After the ruby package is installed, verify the version of ruby whether it is the latest version.

root@linuxhelp:/home/user1# ruby -v
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]

Use the following command in order to get the latest version of lolcat from the git repository.

root@linuxhelp:/home/user1# wget https://github.com/busyloop/lolcat/archive/master.zip
--2016-04-22 15:03:50--  https://github.com/busyloop/lolcat/archive/master.zip
Resolving github.com (github.com)... 192.30.252.129
Connecting to github.com (github.com)|192.30.252.129|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/busyloop/lolcat/zip/master [following]
--2016-04-22 15:03:52--  https://codeload.github.com/busyloop/lolcat/zip/master
Resolving codeload.github.com (codeload.github.com)... 192.30.252.161
Connecting to codeload.github.com (codeload.github.com)|192.30.252.161|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: ‘ master.zip’ 
master.zip              [      < =>              ] 198.51K   135KB/s   in 1.5s   
2016-04-22 15:03:55 (135 KB/s) - ‘ master.zip’  saved [203272]

Now unzip the downloaded master.zip file

root@linuxhelp:/home/user1# unzip master.zip
Archive:  master.zip
344e77462f8bab208f776b29bbcf63778aabd7af
   creating: lolcat-master/
 extracting: lolcat-master/.gitignore  
  inflating: lolcat-master/Gemfile   
  inflating: lolcat-master/LICENSE   
  inflating: lolcat-master/README.md  
 extracting: lolcat-master/Rakefile  
   creating: lolcat-master/ass/
.
.
.
  inflating: lolcat-master/lib/lolcat/cat.rb  
  inflating: lolcat-master/lib/lolcat/lol.rb  
 extracting: lolcat-master/lib/lolcat/version.rb  
  inflating: lolcat-master/lolcat.gemspec  
root@linuxhelp:/home/user1# cd lolcat-master/bin/
root@linuxhelp:/home/user1/lolcat-master/bin# gem install lolcat
Fetching: paint-1.0.1.gem (100%)
Successfully installed paint-1.0.1
Fetching: trollop-2.1.2.gem (100%)
Successfully installed trollop-2.1.2
Fetching: lolcat-42.1.43.gem (100%)
Successfully installed lolcat-42.1.43
Parsing documentation for lolcat-42.1.43
Installing ri documentation for lolcat-42.1.43
Parsing documentation for paint-1.0.1
Installing ri documentation for paint-1.0.1
Parsing documentation for trollop-2.1.2
Installing ri documentation for trollop-2.1.2
Done installing documentation for lolcat, paint, trollop after 1 seconds
3 gems installed

Now the installation of Lolcat is completed successfully. Let us verify the version now.

root@linuxhelp:/home/user1# lolcat -v
lolcat 42.0.99 (c)2011 moe@busyloop.net

To know available options

Use the following command to know the available options.

root@linuxhelp:/home/user1/lolcat-master/bin# lolcat -h 

Now Lolcat command can be Pipelined with the commands such as ll,cal and cat shown below.

root@linuxhelp:~# ll | lolcat

root@linuxhelp:~# cal | lolcat

root@linuxhelp:/home/user1# lolcat file.txt

Here we are going to use lolcat command along with cowsay utility. You have to first install it by using any of the below commands

For CentOS/RedHat

# yum install cowsay

For Fedora

# dnf install cowsay  

For Ubuntu/Debian

root@linuxhelp:~# apt-get install cowsays

Simple usage of lolcat with cowsay

root@linuxhelp:~# cowsay My linuxhelp | lolcat

You can animate a text in rainbow colors as follows

root@linuxhelp:~# cowsay My linuxhelp | lolcat -a -d 30

The -a option is used for animation and -d option is used for duration. Use lolcat command by changing the frequency “ -F”

root@linuxhelp:~# cowsay My linuxhelp | lolcat -a -F 10


Use lolcat command along with spreading option” -p” (i.e.spreading of colors)

root@linuxhelp:~# cowsay My linuxhelp | lolcat -a -p 10


Use lolcat command along with speed option” -s”

Now print the list of all the animals in cowsay such as:

root@linuxhelp:~# cowsay -l
Cow files in /usr/share/cowsay/cows:
apt beavis.zen bong bud-frogs bunny calvin cheese cock cower daemon default
dragon dragon-and-cow duck elephant elephant-in-snake eyes flaming-sheep
ghostbusters gnu head-in hellokitty kiss kitty koala kosh luke-koala
mech-and-cow meow milk moofasa moose mutilated pony pony-smaller ren sheep
skeleton snowman sodomized-sheep stegosaurus stimpy suse three-eyes turkey
turtle tux unipony unipony-smaller vader vader-koala www

Output of cowsay with “ cock” and pipelined with lolcatcowfile.

root@linuxhelp:~# cowsay -f cock My linuxhelp | lolcat

You can also use lolcat with any other command and get colored output in your terminal.

Tag : Lolcat
FAQ
Q
How to animate the text in rainbow using lolcat command?
A
Animate a text in rainbow of colours, as:

$ echo I ❤ Tecmint | lolcat -a -d 500Animate a text in rainbow of colours, as:

$ echo I ❤ Tecmint | lolcat -a -d 500
Q
How to use the lolcat command to display the script file?
A
Use lolcat to display codes of a script file as:

# lolcat test.sh
Q
What is the usage of the Lolcat?
A
Before starting usage of lolcat, make sure to know the available options and help using following command.

# lolcat -h
Q
this command is so colourful thanks
A
keep following us www.linuxhelp.com
Q
any other commands like this
A
sl, fortune, xcowsay, cmatrix, for more refer https://www.linuxhelp.com/funny-commands-in-linux-with-examples/