diff options
author | jaseg <s@jaseg.de> | 2013-07-29 18:51:18 +0200 |
---|---|---|
committer | jaseg <s@jaseg.de> | 2013-07-29 18:51:18 +0200 |
commit | a79ab969533320582482856758394e74739b152e (patch) | |
tree | 59e320c15a282cb57318683815c8e3d529e2f087 /resolvecolor | |
parent | 62e62f1eace5899d0176ef0dd1b66c6ef72f7ab0 (diff) | |
download | pixelterm-a79ab969533320582482856758394e74739b152e.tar.gz pixelterm-a79ab969533320582482856758394e74739b152e.tar.bz2 pixelterm-a79ab969533320582482856758394e74739b152e.zip |
Made a proper python package out of this.
Diffstat (limited to 'resolvecolor')
-rwxr-xr-x | resolvecolor | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/resolvecolor b/resolvecolor new file mode 100755 index 0000000..7dc6537 --- /dev/null +++ b/resolvecolor @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import os, sys, argparse, os.path, json, re +from pygments.formatters import terminal256 + +formatter = terminal256.Terminal256Formatter() + +# Resolve HTML-style hex RGB color codes to xterm-256color color numbers + +if len(sys.argv) != 2: + print('Usage: resolvecolor.py #RRGGBB') + exit() + +print(formatter._closest_color(*[int(s, 16) for s in re.match('#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})', sys.argv[1]).groups()])) + |