Simply run:
python3 hextract.py path/to/file.tmTheme
(could be any readable file format)
Output:
All unique hex colors, printed line by line. (Case ignored.)
import re
import sys
PATH = sys.argv[1]
pat = re.compile(r"#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})")
with open(PATH, 'r') as content_file:
content = content_file.read()
matches = re.findall(pat, content)
matches = [x.upper() for x in matches] # ignoring case
matches = list(set(matches)) # removing duplicates
if not matches:
print("No hex colors found")
else:
for m in matches:
print("#" + m)