Skip to content

Commit 4e0b9da

Browse files
committed
Add Windows Terminal export
1 parent f123e8c commit 4e0b9da

5 files changed

Lines changed: 78 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ dist
44
coverage
55
playwright-report
66
test-results
7+
TODO.md
78
js/compiled.js
89
css/_compiled_main.css
910
css/merged.css

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Put the generated file to `~/.config/alacritty/alacritty.yml`.
4343
* __Mintty:__
4444
Copy the colors and save them in `~/.minttyrc`.
4545

46+
* __Windows Terminal:__
47+
Copy the generated JSON object into the `schemes` array in Windows Terminal `settings.json`, then select `4bit` as the profile color scheme.
48+
4649
* __Other terminals:__
4750
Generate one of the supported formats and copy hex values into the configuration file, preferences panel, or import tool of your terminal.
4851

src/infrastructure/serialization/scheme-exporters.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import { serializeKonsole } from './scheme-exports/konsole';
77
import { serializeMintty } from './scheme-exports/mintty';
88
import { serializePutty } from './scheme-exports/putty';
99
import { serializeTerminator } from './scheme-exports/terminator';
10+
import { serializeWindowsTerminal } from './scheme-exports/windows-terminal';
1011
import { serializeXfceTerminal } from './scheme-exports/xfce-terminal';
1112
import { serializeXresources } from './scheme-exports/xresources';
1213

1314
const TEXT_MIME_TYPE = 'text/plain;charset=utf-8';
15+
const JSON_MIME_TYPE = 'application/json;charset=utf-8';
1416
const XML_MIME_TYPE = 'application/xml;charset=utf-8';
1517

1618
const EXPORT_BUILDERS = {
@@ -24,6 +26,7 @@ const EXPORT_BUILDERS = {
2426
mintty: serializeMintty,
2527
putty: serializePutty,
2628
terminator: serializeTerminator,
29+
windowsTerminal: serializeWindowsTerminal,
2730
};
2831

2932
export const SCHEME_DOWNLOADS = [
@@ -99,6 +102,14 @@ export const SCHEME_DOWNLOADS = [
99102
downloadName: 'config',
100103
mimeType: TEXT_MIME_TYPE,
101104
},
105+
{
106+
id: 'windowsTerminal',
107+
buttonId: 'windows-terminal-button',
108+
text: 'windows terminal',
109+
linkLabel: '*.json',
110+
downloadName: '4bit-windows-terminal.json',
111+
mimeType: JSON_MIME_TYPE,
112+
},
102113
{
103114
id: 'xfceTerminal',
104115
buttonId: 'xfce-terminal-button',
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { colorHex } from './shared';
2+
3+
export function serializeWindowsTerminal(colors) {
4+
return JSON.stringify({
5+
name: '4bit',
6+
black: colorHex(colors.black),
7+
red: colorHex(colors.red),
8+
green: colorHex(colors.green),
9+
yellow: colorHex(colors.yellow),
10+
blue: colorHex(colors.blue),
11+
purple: colorHex(colors.magenta),
12+
cyan: colorHex(colors.cyan),
13+
white: colorHex(colors.white),
14+
brightBlack: colorHex(colors.brightBlack),
15+
brightRed: colorHex(colors.brightRed),
16+
brightGreen: colorHex(colors.brightGreen),
17+
brightYellow: colorHex(colors.brightYellow),
18+
brightBlue: colorHex(colors.brightBlue),
19+
brightPurple: colorHex(colors.brightMagenta),
20+
brightCyan: colorHex(colors.brightCyan),
21+
brightWhite: colorHex(colors.brightWhite),
22+
background: colorHex(colors.background),
23+
foreground: colorHex(colors.foreground),
24+
cursorColor: colorHex(colors.foreground),
25+
selectionBackground: colorHex(colors.brightBlack),
26+
}, null, 2);
27+
}

tests/infrastructure/serialization/scheme-exporters.test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,42 @@ describe('SchemeExporters', () => {
9393
}
9494
});
9595

96+
it('generates a Windows Terminal JSON scheme', async () => {
97+
const blob = buildSchemeDownload('windowsTerminal', createColors());
98+
const scheme = JSON.parse(await blob.text());
99+
const terminalColorKeys = [
100+
'black',
101+
'red',
102+
'green',
103+
'yellow',
104+
'blue',
105+
'purple',
106+
'cyan',
107+
'white',
108+
'brightBlack',
109+
'brightRed',
110+
'brightGreen',
111+
'brightYellow',
112+
'brightBlue',
113+
'brightPurple',
114+
'brightCyan',
115+
'brightWhite',
116+
];
117+
118+
expect(blob.type).toBe('application/json;charset=utf-8');
119+
expect(scheme.name).toBe('4bit');
120+
expect(scheme.background).toBe('#101010');
121+
expect(scheme.foreground).toBe('#F0F0F0');
122+
expect(scheme.cursorColor).toBe('#F0F0F0');
123+
expect(scheme.selectionBackground).toBe('#808080');
124+
expect(scheme.purple).toBe('#AA00AA');
125+
expect(scheme.brightPurple).toBe('#FF55FF');
126+
127+
terminalColorKeys.forEach((key) => {
128+
expect(scheme[key]).toMatch(/^#[0-9A-F]{6}$/);
129+
});
130+
});
131+
96132
it('throws for unknown export formats', () => {
97133
expect(() => buildSchemeDownload('unknown-format', createColors())).toThrow(
98134
'Unknown export format: unknown-format'

0 commit comments

Comments
 (0)