Skip to content

Instantly share code, notes, and snippets.

@evantahler
Created March 23, 2011 00:34
Show Gist options
  • Save evantahler/882400 to your computer and use it in GitHub Desktop.
Save evantahler/882400 to your computer and use it in GitHub Desktop.
A note on how to color stuff in the shell
echo $'\033[31mChoose one of the following persons:\033[0m SOMETHNG ELSE'
def color(text, color_code)
color_enabled? ? "#{color_code}#{text}\e[0m" : text
end
def bold(text)
color(text, "\e[1m")
end
def white(text)
color(text, "\e[37m")
end
def green(text)
color(text, "\e[32m")
end
def red(text)
color(text, "\e[31m")
end
def magenta(text)
color(text, "\e[35m")
end
def yellow(text)
color(text, "\e[33m")
end
def blue(text)
color(text, "\e[34m")
end
def grey(text)
color(text, "\e[90m")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment