Skip to content

Instantly share code, notes, and snippets.

@embayer
Last active December 8, 2015 20:40
Show Gist options
  • Save embayer/628204ce35db528d7373 to your computer and use it in GitHub Desktop.
Save embayer/628204ce35db528d7373 to your computer and use it in GitHub Desktop.
Colorful shell output
def color_print(msg, color):
colors = { "clear": "\033[0;m",
"gray": "\033[1;30m",
"red": "\033[1;31m",
"green": "\033[1;32m",
"yellow": "\033[1;33m",
"blue": "\033[1;34m",
"magenta": "\033[1;35m",
"cyan": "\033[1;36m",
"white": "\033[1;37m",
"crimeson": "\033[1;38m",
"red2": "\033[1;41m",
"green2": "\033[1;42m",
"brown": "\033[1;43m",
"blue2": "\033[1;44m",
"magenta2": "\033[1;45m",
"cyan_hl": "\033[1;46m",
"gray_hl": "\033[1;47m",
"crimson_hl": "\033[1;48m"}
print("{}{}{}".format(colors[color], msg, colors["clear"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment