From 82cac0a5a211d573190253d3b40f89892bda713f Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 16 Sep 2013 15:33:01 +0200 Subject: Fixed script installation --- pixelterm/resolvecolor.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 pixelterm/resolvecolor.py (limited to 'pixelterm/resolvecolor.py') diff --git a/pixelterm/resolvecolor.py b/pixelterm/resolvecolor.py new file mode 100755 index 0000000..83c1330 --- /dev/null +++ b/pixelterm/resolvecolor.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +def main(): + import os, sys, argparse, os.path, json, re + import xtermcolors + + # Resolve HTML-style hex RGB color codes to xterm-256color color numbers + + if len(sys.argv) != 2: + print('Usage: resolvecolor.py #RRGGBB') + exit() + + print(xtermcolors.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()])) + +if __name__ == '__main__': + main() + -- cgit