Created
August 22, 2015 07:41
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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