Last active
November 20, 2017 15:36
-
-
Save rebelwarrior/8731221 to your computer and use it in GitHub Desktop.
Color String Module for quick color in CLI apps
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
##### ======= 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