Skip to content

Instantly share code, notes, and snippets.

@xoebus
Created April 4, 2010 22:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xoebus/355760 to your computer and use it in GitHub Desktop.
Save xoebus/355760 to your computer and use it in GitHub Desktop.
ANSI Colours for Ruby
class String
[:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white].each_with_index do |color, i|
define_method color do "\033[1;#{30+i}m#{self}\033[0m" end
define_method :"#{color}ish" do "\033[0;#{30+i}m#{self}\033[0m" end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment