diff options
Diffstat (limited to 'pixelterm/resolvecolor.py')
-rwxr-xr-x | pixelterm/resolvecolor.py | 17 |
1 files changed, 17 insertions, 0 deletions
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() + |