Skip to content

Instantly share code, notes, and snippets.

@pta2002
Created August 20, 2019 12:48
Show Gist options
  • Save pta2002/ccc609af889e9313731594a56d76adda to your computer and use it in GitHub Desktop.
Save pta2002/ccc609af889e9313731594a56d76adda to your computer and use it in GitHub Desktop.
Preview GIMP palettes in your terminal
#!/bin/env python3
# Requirements: truecolor
# Usage: colorpreview [file]
import truecolor
import sys
assert(len(sys.argv) >= 2)
for filename in sys.argv[1:]:
with open(filename) as file:
text = file.read()
print(filename + ":")
for line in text.split('\n')[1:]:
line = line.strip()
if len(line) == 0 or line[0] == "#": continue
line = line.split()
color = list(map(int, line[:3]))
color_block = truecolor.color_text(" ", background=color)
print(color_block, "{:3} {:3} {:3}".format(*color), line[3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment