Skip to content

Instantly share code, notes, and snippets.

@equivalent
Created October 15, 2019 11:18
Show Gist options
  • Save equivalent/74b1dec423f186c6e594f00b9aacff10 to your computer and use it in GitHub Desktop.
Save equivalent/74b1dec423f186c6e594f00b9aacff10 to your computer and use it in GitHub Desktop.
ruby collor string

If you want to have color strings for Unix Ruby string and you don't want to use gem like colorize

class String
def red; "\e[#{31}m#{self}\e[0m"; end
def green; "\e[#{32}m#{self}\e[0m"; end
def yellow; "\e[#{33}m#{self}\e[0m"; end
def blue; "\e[#{34}m#{self}\e[0m"; end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment