Lolcat, Colorls, Catpix, and other Ruby Gems to add color to your terminal

As well as making your terminal more colorful and productive through the prompt theme, font, and plugins , you can add even more features by using Ruby Gems, such as lolcat, colorls, and catpix.
To use them, ensure you have Ruby installed on your computer, and then you can install each one using the command gem install <GEM_NAME> .

lolcat

This Gem adds a rainbow gradient to anything that you pipe through to it. The image at the top of the post pipes ASCII art text generated with the aarti Gem through lolcat to create a colorful heading in the terminal.
You can combine extra bash commands to animate it, in this case echo to print the string passed to it, -a to animate, and -d for duration.


echo I ❤ Ruby | lolcat -a -d 500

There is a Gem based on lolcat called lolize , which adds the rainbow colour to Ruby output. One use of it is to generate more colourful logs for your Ruby on Rails projects.

Artii

The Artii gem generates ASCII art based on text you pass to it as arguments. You can see this demonstrated in the header image at the top of this tutorial. If you pass the output to lolcat you get ascii art text with multiple colors.


artii 'Ruby Gems' --font slant | lolcat

It is based on the Figlet library, which you can also install on a Mac with brew install figlet .

Colorls

This enhances the terminal command ls with color and icons. Below is a screenshot from its Github repo . This configuration is an iTerm2 terminal (Mac OS), with oh-my-zsh with powerlevel9k theme and powerline nerd-font + awesome-config font with the Solarized Dark color theme.
You can make it as easy to use as ls by adding an alias for lc to your ~/.bashrc or ~/.zshrc file.


alias lc="colorls"

Catpix

This converts images to a format that can render on a terminal screen. You can try having an image loaded into your terminal when it starts or when there is an event — for example when your tests pass.

Find out more

These are just some of the Ruby Gems that can enhance your terminal, and learning how they work means you can customize your command line. You could even take it further by adding a special setup for irb and pry , such as irbtools .

Find out more about the Gems on Github

  • lolcat
  • lolize
  • colorls
  • catpix
  • artii

Read more from ryanwhocodes on Medium

  • Make your terminal more colourful and productive with iTerm2 and Zsh!
  • Powerlevel9k: personalise your prompt for any programming language
  • Top 10 Bash file system commands you can’t live without

Recommended books on Ruby programming

I have found these books helpful when learning to program Ruby and develop Rails applications. These contain Amazon affiliate links. If you click through & make a purchase, I will earn a commission at no additional cost to you.

  • The Well Grounded Rubyist by David A. Black — This explains the fundamentals of Ruby programming in a clear, comprehensive way.
  • Practical Object Oriented Design in Ruby by Sandi Metz — Covers how to design classes and other Ruby objects using OOP design.
  • Effective Testing With RSpec 3 by Myron Marston and Ian Dees — Teaches the syntax and best practices for Ruby’s RSpec testing library.

This content was originally published here.

User Input