ryanwhocodes Jun 20, 2018 · 2 min read

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

Ruby gems to generate creative output in your terminal.

As well as making your terminal more colorful through your shell prompt theme, font, and color settings, you can add even more features by using Ruby gems, such as artii, lolcat, colorls, and catpix.

Contents

Setup Ruby

To use them, ensure you have Ruby installed on your computer, and then you can install each one using the command gem install. For example:

gem install lolcat

Lolcat and Artii

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 Artii gem through lolcat to create a colorful heading in the terminal.

artii 'Ruby Gems' --font slant | lolcat

Ruby gem - lolcat

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.

The Lolize gem in action coloring Ruby on Rails logs

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.

Ruby gem - colorls

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.

Ruby gem - catpix

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.

Ruby too slow?

Ruby is a high-level interpreted programming language, so can be slower for certain tasks than compiled and lower level programming languages. If you like the idea of these, but concerned about speed, then you might find some alternatives written in languages such as Bash, Rust or Go.