How to use rainbow colors in linux terminal


This article is for those who believe that Linux command line is boring and there is not much fun. To create an interesting colorful setting lolcat utility can be used, which produces rainbow colors in Linux terminal. Lolcat utility works for Linux, BSD and OSX which concatenates like similar to cat command.

Installing Lolcat

Lolcat utility is one of the gem in Ruby programming language. Hence, if you would like to practice this tip, it is essential to install the latest version of Ruby.

To install Ruby use the following command –

$ sudo apt-get install ruby

The sample output should be like this –

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gcc-4.8-base:i386 libasn1-8-heimdal:i386 libasound2:i386
libasound2-plugins:i386 libasyncns0:i386 libavahi-client3:i386
libavahi-common-data:i386 libavahi-common3:i386 libbit-vector-perl
libcapi20-3:i386 libcarp-clan-perl libclass-method-modifiers-perl
libcups2:i386 libdata-random-perl libdate-calc-perl libdate-calc-xs-perl
libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386
libdrm-radeon1:i386 libedit2:i386 libelf1:i386 libexif12:i386 libexpat1:i386
libffi6:i386 libflac8:i386 libfontconfig1:i386 libfreetype6:i386
libgcrypt11:i386 libgd-perl libgd3:i386 libgif4:i386
libgl1-mesa-dri-lts-wily:i386 libgl1-mesa-glx-lts-wily:i386
libglapi-mesa-lts-wily:i386 libglib2.0-0:i386 libglu1-mesa:i386
libgnome2-gconf-perl libgnutls26:i386 libgpg-error0:i386 libgphoto2-6:i386
libgphoto2-port10:i386 libgssapi-krb5-2:i386 libgssapi3-heimdal:i386
libgstreamer-plugins-base0.10-0:i386 libgstreamer0.10-0:i386
libhcrypto4-heimdal:i386 libheimbase1-heimdal:i386 libheimntlm0-heimdal:i386
libhx509-5-heimdal:i386 libice6:i386 libieee1284-3:i386
libjack-jackd2-0:i386 libjbig0:i386 libjpeg-turbo8:i386 libjpeg8:i386
libk5crypto3:i386 libkeyutils1:i386 libkrb5-26-heimdal:i386 libkrb5-3:i386
libkrb5support0:i386 liblcms2-2:i386 libldap-2.4-2:i386 libllvm3.6:i386
libltdl7:i386 libmouse-perl libmpg123-0:i386 libnet-dropbox-api-perl
libogg0:i386 libopenal1:i386 liborc-0.4-0:i386 libosmesa6:i386
.................................

To verify the version of ruby, use the following command –

$ sudo ruby --version

The sample output should be like this –

ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]

To get the Lolcat from git repository, use the following command-

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

The sample output should be like this –

--2016-03-10 11:43:00-- https://github.com/busyloop/lolcat/archive/master.zip
Resolving github.com (github.com)... 192.30.252.128
Connecting to github.com (github.com)|192.30.252.128|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/busyloop/lolcat/zip/master [following]
--2016-03-10 11:43:01-- 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’
[ <=> ] 2,03,272 234KB/s in 0.8s
2016-03-10 11:43:03 (234 KB/s) - ‘master.zip’ saved [203272]

To unzip master.zip file, use the following command –

$ unzip master.zip

The sample output should be like this –

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/ass/screenshot.png
creating: lolcat-master/bin/
inflating: lolcat-master/bin/lolcat
creating: lolcat-master/lib/
inflating: lolcat-master/lib/lolcat.rb
creating: lolcat-master/lib/lolcat/
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

To enter into lolcat-master/bin directory, use the following command –

$ cd lolcat-master/bin

To install lolcat gem use the following command –

$ gem install lolcat

The sample output should be like this –

$ sudo gem install lolcat

The sample output should be like this –

Fetching: paint-1.0.1.gem (100%)
Fetching: trollop-2.1.2.gem (100%)
Fetching: lolcat-42.1.43.gem (100%)
Successfully installed paint-1.0.1
Successfully installed trollop-2.1.2
Successfully installed lolcat-42.1.43
3 gems installed
Installing ri documentation for paint-1.0.1...
Installing ri documentation for trollop-2.1.2...
Installing ri documentation for lolcat-42.1.43...
Installing RDoc documentation for paint-1.0.1...
Installing RDoc documentation for trollop-2.1.2...
Installing RDoc documentation for lolcat-42.1.43..

To get Lolcat version, use the following command –

$ lolcat --version

The sample output should be like this –

lolcat 42.1.43 (c)2011 moe@busyloop.net

To get the available option in lolcat, use the following command –

$ lolcat -h

The sample output should be like this –

To print the text with Lolcat, use the following command –

$ echo I love Tutorialspoint | lolcat
$ figlet I love Tutorialspoint | lolcat

The sample output should be like this –

In the above command, please note that, we have used figlet.

To install figlet, use the following command –

$ sudo apt-get install figlet

To install  Lolcat with cowsay, use the following command –

$ sudo apt-get install cowsay

The sample output should be like this –

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gcc-4.8-base:i386 libasn1-8-heimdal:i386 libasound2:i386
libasound2-plugins:i386 libasyncns0:i386 libavahi-client3:i386
libavahi-common-data:i386 libavahi-common3:i386 libbit-vector-perl
libcapi20-3:i386 libcarp-clan-perl libclass-method-modifiers-perl
libcups2:i386 libdata-random-perl libdate-calc-perl libdate-calc-xs-perl
libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386
libdrm-radeon1:i386 libedit2:i386 libelf1:i386 libexif12:i386 libexpat1:i386
libffi6:i386 libflac8:i386 libfontconfig1:i386 libfreetype6:i386
libgcrypt11:i386 libgd-perl libgd3:i386 libgif4:i386
libgl1-mesa-dri-lts-wily:i386 libgl1-mesa-glx-lts-wily:i386
libglapi-mesa-lts-wily:i386 libglib2.0-0:i386 libglu1-mesa:i386
libgnome2-gconf-perl libgnutls26:i386 libgpg-error0:i386 libgphoto2-6:i386
libgphoto2-port10:i386 libgssapi-krb5-2:i386 libgssapi3-heimdal:i386
libgstreamer-plugins-base0.10-0:i386 libgstreamer0.10-0:i386
......................................................

cowsay  command supports a lot of other visual graphical animals is shown in the following lines.

To get the list of animals, use the following command –

$ cowsay -l

The sample output should be like this –

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

As an example, the below image of a pony was created using lolcat utility.

Use the following command to get the output –

$ cowsay -f pony I love tutorialspoint | lolcat

The sample output will be something like the below –

Congratulations! Now, you know “How to use Rainbow Colors in Linux Terminal”. We’ll learn more about these types of commands in our next Linux post. Keep reading!

Lakshmi Srinivas
Lakshmi Srinivas

Programmer / Analyst / Technician

Updated on: 21-Oct-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements