Created
May 16, 2023 18:22
-
-
Save creaktive/95681a9b640277236cc6d7b36d3a9ba5 to your computer and use it in GitHub Desktop.
iTerm2 color scheme parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use 5.036; | |
local $/ = undef; | |
$_ = <>; | |
while ( | |
m{ | |
(?(DEFINE) | |
(?<float> \d+\.\d+) | |
) | |
<key>(?: | |
Ansi \s+ (?<c>\d+) | |
| | |
(?<n>[^>]+) | |
) \s+ Color</key> \s* | |
<dict> \s* | |
<key>Blue \s+ Component</key> \s* | |
<real>(?<b>(?&float))</real> \s* | |
<key>Color \s+ Space</key> \s* | |
<string>sRGB</string> \s* | |
<key>Green \s+ Component</key> \s* | |
<real>(?<g>(?&float))</real> \s* | |
<key>Red \s+ Component</key> \s* | |
<real>(?<r>(?&float))</real> \s* | |
</dict> | |
}giosx | |
) { | |
my $color = $+{n} | |
? lc($+{n} =~ tr{ }{_}r) | |
: 'color' . $+{c}; | |
printf "%s #%02x%02x%02x\n", | |
$color, | |
255 * $+{r}, | |
255 * $+{g}, | |
255 * $+{b}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
color0 #073642 | |
color1 #dc322f | |
color10 #586e75 | |
color11 #657b83 | |
color12 #839496 | |
color13 #6c71c4 | |
color14 #93a1a1 | |
color15 #fdf6e3 | |
color2 #859900 | |
color3 #b58900 | |
color4 #268bd2 | |
color5 #d33682 | |
color6 #2aa198 | |
color7 #eee8d5 | |
color8 #002b36 | |
color9 #cb4b16 | |
background #002b36 | |
bold #93a1a1 | |
cursor #839496 | |
cursor_text #073642 | |
foreground #839496 | |
selected_text #93a1a1 | |
selection #073642 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment