Skip to content

Instantly share code, notes, and snippets.

@luisparravicini
Last active December 11, 2020 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luisparravicini/8a8155f3dc9070306cacf4192cf8dd6b to your computer and use it in GitHub Desktop.
Save luisparravicini/8a8155f3dc9070306cacf4192cf8dd6b to your computer and use it in GitHub Desktop.
small Ruby helper for colorizing output
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