Colorized Ruby output to the terminal

gmile picture gmile · Sep 28, 2009 · Viewed 142.4k times · Source

Using Ruby, how can I perform background and foreground text colorization for output in the terminal?

I remember, when programming Pascal we all used to write our own textcolor(…) procedures to make our small educational programs look more pretty and presentational.

How would I go about coding an equivalent of that in Ruby?

Answer

jaredmdobson picture jaredmdobson · Sep 28, 2009

Colorize is my favorite gem! :-)

Check it out:

https://github.com/fazibear/colorize

Installation:

gem install colorize

Usage:

require 'colorize'

puts "I am now red".red
puts "I am now blue".blue
puts "Testing".yellow