forked from catppuccin/iterm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ts
executable file
·147 lines (144 loc) · 3.08 KB
/
build.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env -S deno run --allow-write --allow-env
import { variants } from "https://esm.sh/@catppuccin/[email protected]";
import Handlebars from "https://esm.sh/[email protected]";
const template = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
{{#each color}}
<key>{{key}}</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>{{col.red}}</real>
<key>Green Component</key>
<real>{{col.green}}</real>
<key>Blue Component</key>
<real>{{col.blue}}</real>
<key>Alpha Component</key>
<real>{{col.alpha}}</real>
</dict>
{{/each}}
</dict>
</plist>`;
for (let [flavour, colors] of Object.entries(variants)) {
const isLatte = flavour === "latte";
colors = Object.fromEntries(
Object.entries(colors).map(([key, value]) => {
const [red, green, blue] = [
value.hex.slice(1, 3),
value.hex.slice(3, 5),
value.hex.slice(5, 7),
].map((v) => parseInt(v, 16) / 255);
return [key, { red, green, blue, alpha: 1 }];
}),
);
const termcolor = [
{
key: "Ansi 0 Color",
col: isLatte ? colors.subtext1 : colors.surface1,
},
{
key: "Ansi 1 Color",
col: colors.red,
},
{
key: "Ansi 2 Color",
col: colors.green,
},
{
key: "Ansi 3 Color",
col: colors.yellow,
},
{
key: "Ansi 4 Color",
col: colors.blue,
},
{
key: "Ansi 5 Color",
col: colors.pink,
},
{
key: "Ansi 6 Color",
col: colors.teal,
},
{
key: "Ansi 7 Color",
col: isLatte ? colors.surface2 : colors.subtext1,
},
{
key: "Ansi 8 Color",
col: isLatte ? colors.subtext0 : colors.surface2,
},
{
key: "Ansi 9 Color",
col: colors.red,
},
{
key: "Ansi 10 Color",
col: colors.green,
},
{
key: "Ansi 11 Color",
col: colors.yellow,
},
{
key: "Ansi 12 Color",
col: colors.blue,
},
{
key: "Ansi 13 Color",
col: colors.pink,
},
{
key: "Ansi 14 Color",
col: colors.teal,
},
{
key: "Ansi 15 Color",
col: isLatte ? colors.surface1 : colors.subtext0,
},
{
key: "Background Color",
col: colors.base,
},
{
key: "Foreground Color",
col: colors.text,
},
{
key: "Link Color",
col: colors.sky,
},
{
key: "Bold Color",
col: colors.text,
},
{
key: "Cursor Color",
col: colors.rosewater,
},
{
key: "Cursor Text Color",
col: colors.text,
},
{
key: "Cursor Guide Color",
col: { ...colors.text, alpha: 0.07 },
},
{
key: "Selection Color",
col: colors.surface2,
},
{
key: "Selected Text Color",
col: colors.text,
},
];
const compiled = Handlebars.compile(template);
Deno.writeTextFileSync(
`./colors/catppuccin-${flavour}.itermcolors`,
compiled({ color: termcolor }),
);
}