Get a Rainbow of Colors for Terminal Command Output with lolcat

Jul 3, 2014 - 6 Comments

lolcat rainbow color command output for Terminal

The Terminal defaults to being a bunch of boring black on white text, and sure you can change the appearance to other themes, add colors, background images, opacity, transparencies, and other UI customizations, but what you really want is obviously a rainbow version of the cat command for input and output, right? Right, of course you want rainbow output, who wouldn’t want that?

That’s where the lolcat command line utility comes in, because lolcat is a concatenate utility that can serve as a very colorful cat replacement, or take any standard input and dump the output as a rainbow of text. Is this useful? Well, that’s up to you to decide, but it sure is fun and more lively looking.

Note: in case it wasn’t obvious yet, this is kind of a joke, but lolcat legitimately does work as a functioning cat replacement. Because this is entirely contained within the command line, it’s best reserved for advanced users who are comfortable using Terminal… and who want rainbow output.

Installing lolcat in the Mac OS X Terminal

You’ll need to have ruby installed on the Mac to be able to use gem, the installer, and then installing lolcat is a piece of cake:

gem install lolcat

That should install lolcat just fine, but if you get a write permissions error like this:

“ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /Library/Ruby/Gems/2.0.0 directory.”

You can either adjust the permissions of the gems directory to include your uid, or just use sudo to write to it anyway:

sudo gem install lolcat

Installing should only take a minute or two to complete.

Uisng lolcat to Make Output a Rainbow

With installation of lolcat out of the way, you’re ready to use lolcat and get colorful. Refresh your terminal or launch a new one and you’re ready to go. You can get an initial look by printing the lolcat help file:

lolcat -h

You’ll then see the most colorful help text ever made.

lolcat rainbow terminal cat output

But why stop there? You can pipe anything into lolcat and make it a rainbow as well:

ps aux|grep root|lolcat

Or use lolcat to display some code in a lovely rainbow:

lolcat ~/dev/scripty.py

If you want some extra amazement, the -a flag is particularly exciting because it creates an animated rainbow effect of cycling colors, which is basically the peak of human innovation.

For example, this will animate the  Apple logo in a rainbow for a count of 500:

echo |lolcat -a -d 500

Want a colorful block of ascii art? Use cowsay or banner:

banner osxdaily.com|lolcat

The possibilities are endless.

The lolcat utility is open source, those interested can view the project page on github.

.

Related articles:

Posted by: Paul Horowitz in Command Line, Fun

6 Comments

» Comments RSS Feed

  1. Calvin Wheatley says:

    after entering the sudo gem install lolcat – it asks for a password..? what is it?

  2. Emory Schley says:

    Is there a way to increase the point size of the text in the Terminal window? My ancient eyes are having difficulty with the tiny text, and would appreciate some relief! ;-)

  3. Anubhav says:

    A typo:

    “Uisng” lolcat to Make Output a Rainbow

  4. Rod says:

    Can’t get the command ‘echo |lolcat -a -d 500’ to work.

    The return is three question marks. If I use ‘sudo echo …’ then those question marks are displayed in red.

    I’m using OS 10.6.8.

    The lolcat help file is displayed in a rainbow version.

  5. Paul says:

    Oh and for those who want cowsay too, which draws a silly ASCII character to speak a message, you can also install that through gem:

    gem install cowsay

    Then combine cowsay with lolcat:

    cowsay "hello this is your colorful message"|lolcat

    Yup.

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site