summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Toso <victortoso@redhat.com>2016-02-12 17:13:13 +0100
committerVictor Toso <victortoso@redhat.com>2016-02-12 17:13:13 +0100
commit58f4e26a8fed22130c1091de8861e9fd553eed82 (patch)
tree225b128654adddccaf25b42144a3f9ec55e10591
parent7b00475080063056e8c2e868220425d7196167f5 (diff)
colortest: for cmdline 256 colors and its codeHEADmaster
This is very useful for me while tweaking my colors in my vim, mutt or terminal. I've only included the line referencing to the original author which is justinabrahms (that is, for this python port)
-rw-r--r--colortest.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/colortest.py b/colortest.py
new file mode 100644
index 0000000..47e7999
--- /dev/null
+++ b/colortest.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+# Ported to Python from http://www.vim.org/scripts/script.php?script_id=1349
+# Original Author: https://gist.github.com/justinabrahms/1047767#file-colortest-py
+
+print "Color indexes should be drawn in bold text of the same color."
+print
+
+colored = [0] + [0x5f + 40 * n for n in range(0, 5)]
+colored_palette = [
+ "%02x/%02x/%02x" % (r, g, b)
+ for r in colored
+ for g in colored
+ for b in colored
+]
+
+grayscale = [0x08 + 10 * n for n in range(0, 24)]
+grayscale_palette = [
+ "%02x/%02x/%02x" % (a, a, a)
+ for a in grayscale
+]
+
+normal = "\033[38;5;%sm"
+bold = "\033[1;38;5;%sm"
+reset = "\033[0m"
+
+for (i, color) in enumerate(colored_palette + grayscale_palette, 16):
+ index = (bold + "%4s" + reset) % (i, str(i) + ':')
+ hex = (normal + "%s" + reset) % (i, color)
+ newline = '\n' if i % 6 == 3 else ''
+ print index, hex, newline,