Skip to content

Instantly share code, notes, and snippets.

@yrsegal
Created August 22, 2015 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yrsegal/c1b55941c73c4f72f7da to your computer and use it in GitHub Desktop.
Save yrsegal/c1b55941c73c4f72f7da to your computer and use it in GitHub Desktop.
prints all term256 colors out. if you chmod +x it, it will run as an executable file.
#!/usr/bin/python
from __future__ import print_function
import argparse, sys
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--flat", help="Print without blocking", dest="flat",
action="store_true")
args = parser.parse_args()
mainbase = "\033[38;5;{}m"
backgroundbase = "\033[48;5;{}m"
reset = "\033[0m"
toprint = [["" for i in range(16)] for i in range(16)]
if __name__ == "__main__":
for i in xrange(0, 256, 16):
for j in xrange(16):
num = i+j
strnum = str(num)
if num < 100:
strnum = "0" + strnum
if num < 10:
strnum = "0" + strnum
toprint[i/16][j] = strnum+" "+mainbase.format(num)+backgroundbase.format(num)+"===="+reset
sep = "\n" if args.flat else " "
if not args.flat:
toprint = map(None, *toprint)
sys.stdout.write("\n".join([sep.join(i) for i in toprint])+"\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment