term-ansicolor – Term::ANSIColor for Ruby


Small Ruby library that colors strings using ANSI escape sequences. It's possible to use constants:

require 'term/ansicolor'
include Term::ANSIColor
print red, bold, "red bold", reset, "\n"

Or unary functions:

include Term::ANSIColor
print red(bold("red bold")), "\n"

Blockforms do also autoreset at the block's end:

include Term::ANSIColor
print red { bold { "red bold" } }, "\n"

It's also possible to use this module as Mixin for classes of objects that respond to :to_str, e. g. String.

class String
  include Term::ANSIColor
print "red bold".red.bold, "\n"


The library can be installed via rubygems:

# gem install term-ansicolor

The gem and the source archive can also be downloaded directly from rubyforge.org.


Florian Frank <flori@ping.de>


This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 2 as published by the Free Software Foundation: GNU GPL.

Valid XHTML 1.0 Transitional