Colors in Ruby Console Using Wirble 20 Dec 2009
Tags: log, console, gem, wirble

If you want to have colors in your console, install the wirble gem (Read the documentation).

For some reason, I can't override the colors when I follow the instructions in the README. In case someone's also experiencing this, you can try merging the colors in the Wirble::Colorize::DEFAULT_COLORS constant. Then call the init and colorize methods.

Here's mine (same as with vim's syntax highlighting for ruby and haml).

ruby
Wirble::Colorize::DEFAULT_COLORS.merge!({
  # delimiter colors
  :comma => :none,
  :refers => :none,

  # container colors (hash and array)
  :open_hash => :purple,
  :close_hash => :purple,
  :open_array => :purple,
  :close_array => :purple,

  # object colors
  :open_object => :light_red,
  :object_class => :white,
  :object_addr_prefix => :blue,
  :object_line_prefix => :blue,
  :close_object => :light_red,

  # symbol colors
  :symbol => :red,
  :symbol_prefix => :red,

  # string colors
  :open_string => :purple,
  :string => :red,
  :close_string => :purple,

  # misc colors
  :number => :red,
  :keyword => :brown,
  :class => :green,
  :range => :none
})