Skip to content

Instantly share code, notes, and snippets.

@rebelwarrior
Last active November 20, 2017 15:36
Show Gist options
  • Save rebelwarrior/8731221 to your computer and use it in GitHub Desktop.
Save rebelwarrior/8731221 to your computer and use it in GitHub Desktop.
Color String Module for quick color in CLI apps
##### ======= Color Strings =======
module ColorString
def red(string)
STDOUT.tty? ? "\033[31m#{string}\033[0m\n" : string #31
end
def green(string)
STDOUT.tty? ? "\033[32m#{string}\033[0m\n" : string #32
end
def yellow(string)
STDOUT.tty? ? "\033[33m#{string}\033[0m\n" : string #33
end
def faint(string)
STDOUT.tty? ? "\x1b[2m#{string}\x1b[0m\n" : string
end
end
include ColorString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment