Skip to content

Instantly share code, notes, and snippets.

@asterite
Created September 5, 2012 15:32
Show Gist options
  • Select an option

  • Save asterite/3638512 to your computer and use it in GitHub Desktop.

Select an option

Save asterite/3638512 to your computer and use it in GitHub Desktop.
Color p and puts in green in Rails console
if Rails.env == 'development' || Rails.env == 'test'
def $stdout.puts_with_color(*args)
print "\033[32m"
puts_without_color *args
print "\033[0m"
end
klass = class << $stdout; self; end
klass.alias_method_chain :puts, :color
module Kernel
def p_with_color(*args)
print "\033[32m"
p_without_color *args
print "\033[0m"
end
alias_method_chain :p, :color
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment