Skip to content

Instantly share code, notes, and snippets.

@casimir
Created November 4, 2015 13:08
Show Gist options
  • Save casimir/b06aeb96b20901fd668a to your computer and use it in GitHub Desktop.
Save casimir/b06aeb96b20901fd668a to your computer and use it in GitHub Desktop.
Display ANSI colours
#!/usr/bin/env python2
import sys
terse = "-t" in sys.argv[1:] or "--terse" in sys.argv[1:]
for i in range(2 if terse else 10):
for j in range(30, 38):
for k in range(40, 48):
if terse:
print "\33[%d;%d;%dm%d;%d;%d\33[m " % (i, j, k, i, j, k),
else:
print ("%d;%d;%d: \33[%d;%d;%dm Hello, World! \33[m " %
(i, j, k, i, j, k, ))
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment