Roll Your Own Color Scheme in Windows Terminal

Thu Sep 30 2021 #Programming#WindowsTerminal

At Build 2019, Microsoft announced an open source terminal for Windows. On 21 June 2019, it became available for preview in the Microsoft Store. I have been playing with it since and while its features are laudable, every developer knows the most important aspect of a terminal is its color scheme.

Luckily, it's easy to write your own. From the Windows Terminal, select the dropdown at the right edge of the tabs. Select Settings. Alternatively, the default keybinding for accessing settings is Ctrl+,.

A Windows Terminal window showing the user accessing settings by the dropdown at the right edge of the tabs.

This will open up a JSON file with the settings for your Terminal in the default editor.

The JSON file for editing Windows Terminal settings edited using Visual Studio Code.

Navigate to the "schemes" key. Here a list of JSON objects map standard Unix terminal colors (except for magenta which is called purple) to HEX codes. Copy an existing scheme and paste it into this list. Now, you can edit the colors as you like. I chose to implement a color scheme from flatuicolors.com called V1. You can find the implementation in a Gist here.

Give your scheme a unique "name" value and set the "profiles" to use that scheme.

As you edit the scheme, the Terminal will update in real time. To check your scheme, I have found the following bash command useful:

for x in {0..8}; do for i in {30..37}; do for a in {40..47}; do echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "; done; echo; done; done; echo ""

This will display every text color on every highlight color. I used it to create this sample for the Gist:

Happy hacking!