Last active
August 29, 2015 14:18
-
-
Save yggie/51095ae4382acfe4756a to your computer and use it in GitHub Desktop.
Show 256 Terminal Colors with Python
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/env python | |
# heavily influenced by: | |
# https://askubuntu.com/questions/27314/script-to-display-all-terminal-colors | |
import sys | |
foreground_only = "-f" in sys.argv[1:] or "--fg-only" in sys.argv[1:] | |
write = sys.stdout.write | |
for fgbg in range(38, 48): | |
for color in range(0, 256): | |
if (((fgbg - 38)*256 + color) % 15 == 0): | |
write("\n") | |
write("\33[%d;5;%dm %02d;5;%03d \33[0m" % (fgbg, color, fgbg, color)) | |
if foreground_only: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment