Last active
December 11, 2020 17:01
-
-
Save luisparravicini/8a8155f3dc9070306cacf4192cf8dd6b to your computer and use it in GitHub Desktop.
small Ruby helper for colorizing output
This file contains 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
module Colors | |
def self.fg_green(io=$stdout) | |
io.print "\x1b[0;32m" | |
end | |
def self.fg_white(io=$stdout) | |
io.print "\x1b[1;37m" | |
end | |
def self.fg_gray(io=$stdout) | |
io.print "\x1b[1;90m" | |
end | |
def self.fg_yellow(io=$stdout) | |
io.print "\x1b[0;33m" | |
end | |
def self.fg_red(io=$stdout) | |
io.print "\x1b[0;31m" | |
end | |
def self.reset(io=$stdout) | |
io.print "\x1b[0m" | |
end | |
def self.reset_at_exit | |
at_exit do | |
Colors.reset($stdout) | |
Colors.reset($stderr) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment