Skip to content

Instantly share code, notes, and snippets.

@philadams-zz
Created February 23, 2013 00:27
Show Gist options
  • Save philadams-zz/5017645 to your computer and use it in GitHub Desktop.
Save philadams-zz/5017645 to your computer and use it in GitHub Desktop.
print all xterm-256 and -16 colors
#! /usr/bin/env python
# Display the colors available in a terminal.
print "16-color mode:"
for color in range(0, 16) :
for i in range(0, 3) :
print "\033[0;%sm%02s\033[m" % (str(color + 30), str(color)),
print
# Programs like ls and vim use the first 16 colors of the 256-color palette.
print "256-color mode:"
for color in range(0, 256) :
for i in range(0, 3) :
print "\033[38;5;%sm%03s\033[m" % (str(color), str(color)),
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment