Created
March 11, 2012 06:08
-
-
Save startling/2015230 to your computer and use it in GitHub Desktop.
Display 256 colors in your terminal, if it supports it.
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
import sys | |
for i, n in enumerate(xrange(232)): | |
# for each color, print two spaces with that background | |
sys.stdout.write("\x1b[48;5;%dm " % n) | |
# and then back to the default color | |
sys.stdout.write("\x1b[49m") | |
# every 6 numbers after the first three, | |
# put in a newline | |
if (i - 3) % 6 == 0: | |
# lazy newlines | |
# colors 232-255 are a grayscale ramp | |
for n in range(232, 256): | |
sys.stdout.write("\x1b[48;5;%dm " % n) | |
sys.stdout.write("\x1b[49m") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment