Skip to content

Instantly share code, notes, and snippets.

@Pr1meSuspec7
Created April 1, 2020 18:01
Show Gist options
  • Save Pr1meSuspec7/55ced5e104954dff339f23d5e24567e4 to your computer and use it in GitHub Desktop.
Save Pr1meSuspec7/55ced5e104954dff339f23d5e24567e4 to your computer and use it in GitHub Desktop.
Simple colorize output
COLORS = {'grey': 30, 'red': 31, 'green': 32, 'yellow': 33, 'blue': 34, 'magenta': 35, 'cyan': 36, 'white': 37}
RESET = '\033[0m'
def colortext(text, color=None):
# Ex: print(colortext('some text', 'cyan'))
ascii_color = '\033[1;%dm%s'
if color is not None:
text = ascii_color % (COLORS[color], text)
text += RESET
return text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment