Created
September 5, 2012 15:32
-
-
Save asterite/3638512 to your computer and use it in GitHub Desktop.
Color p and puts in green in Rails console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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