ScottSpence.com

Scott's Thoughts Pamphlet!

Windows Terminal Config - Make it Your Own

I’ve been using the Windows Terminal now since the summer, it’s great and I now prefer it over Hyper which was my preferred terminal.

Windows Terminal comes with a lot of options for configuration and a load more which I’ve only just discovered after researching this post!

Dope!

ℹ If you know me then you’ll know I love a shortcut key combo, I’ll be peppering this post with all the keyboard shortcuts so you can be as productive as possible when using the Windows Terminal.

Tl;Dr

If you prefer to watch how this is done then skip all the way to the end for a video detailing the process. 🚀

First impressions

When I first opened the app I was greeted with PowerShell as the initial tab, there’s a dropdown menu to choose from one of PowerShell, (default), Command Prompt or Azure Cloud Shell.

default windows terminal appearance

So it looks like the standard Command Prompt (sort of), I went about finding if I could change that and was pleasantly surprised.

The Windows Terminal team have done an awesome job of documenting all aspects of the Terminal.

More on that in the next section!

ℹ To see what available shells you have you can use Ctrl+Shift+Space Bar which will activate the dropdown which will show all available shells.

shell dropdown in windows terminal

Included Themes

The first thing I did was try work out how to change the theme (priorities! 😂) and it wasn’t as simple as adding a string to a plugins array like with Hyper term.

The Windows Terminal has a settings.json file to manage the configuration with a lot of options! I’ll come onto this in a moment, for now I’ll say it’s split into several sections:

  • Profiles
  • Schemes
  • Keybindings

Anyway back to the theme, important stuff right! So there are seven included colour schemes (themes) that come with the Windows Terminal:

To change to any of those I have to open the settings.json with Ctrl+, then I’m presented with the big boi config, I want to apply the theme Tango Dark to every tab that I open in the terminal so I’ll add it in the profiles object:

1"profiles": {
2 "defaults": {
3 // Put settings here that you want to apply to all profiles.
4 "colorScheme": "Tango Dark"
5 },
6}

Other config options

There’s also some other config options I like to set for the defaults, these are the font, font size and the cursor shape and colour:

1"profiles": {
2 "defaults": {
3 // Put settings here that you want to apply to all profiles.
4 "fontFace": "Victor Mono",
5 "fontSize": 15,
6 "colorScheme": "Tango Dark",
7 "cursorShape": "filledBox",
8 "cursorColor": "#639"
9 // "cursorHeight": 85 // use with vintage cursorShape
10 }
11}

ℹ I discovered the additional cursor options by hitting Ctrl+space bar to bring up the intellisense options:

intellisense options

Use your own Theme

You may have noticed in the last image there that the theme isn’t one of the provided themes.

I wasn’t happy with the provided theming options so went to find a custom one to use, luckily for me there’s Windows Terminal Themes which is a a very large selection of pre made themes.

If you’re tired of looking through the themes on the website you can check out the Windows Terminal Themes GitHub themes.json file (it’s a chonka!).

You can create your own theme in the Windows Terminal but I went for one of the ones available on the Windows Terminal Themes site Builtin Solarized Dark.

The way to use it is, copy the theme object from the site and paste it into the schemes array part of the settings.json file.

In it’s initial state the schemes array is empty:

1// Add custom color schemes to this array.
2// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
3"schemes": [],

I add the theme object to the schemes array then I need to set it for the default, which means any tab I open for Ubuntu, Debian etc will have the same theme.

The shemes array with the new theme in there:

1// Add custom color schemes to this array.
2// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
3"schemes": [
4 {
5 "name": "Builtin Solarized Dark",
6 "black": "#073642",
7 "red": "#dc322f",
8 "green": "#859900",
9 "yellow": "#b58900",
10 "blue": "#268bd2",
11 "purple": "#d33682",
12 "cyan": "#2aa198",
13 "white": "#eee8d5",
14 "brightBlack": "#002b36",
15 "brightRed": "#cb4b16",
16 "brightGreen": "#586e75",
17 "brightYellow": "#657b83",
18 "brightBlue": "#839496",
19 "brightPurple": "#6c71c4",
20 "brightCyan": "#93a1a1",
21 "brightWhite": "#fdf6e3",
22 "background": "#002b36",
23 "foreground": "#839496"
24 }
25]

Then in profiles, defaults section I add in the colour scheme:

1"profiles": {
2 "defaults": {
3 // Put settings here that you want to apply to all profiles.
4 "fontFace": "Victor Mono",
5 "fontSize": 15,
6 "colorScheme": "Builtin Solarized Dark",
7 "cursorShape": "filledBox",
8 "cursorColor": "#639"
9 // "cursorHeight": 85 // use with vintage cursorShape
10 }
11}

Bingo bango, new theme for all my new terminal tabs I open!

Profiles

So I can have a nice theme for the terminal now, nice font, yay! What now if I want to have a different theme for when I’m in Ubuntu and Debian? (I use a lot of Windows Subsystem for Linux instances)

In the profiles section of the settings.json I have a profile for each shell available to me on my machine.

These are autogenerated each time I add in a WSL instance but the default ones are for PowerShell, Command Prompt and Azure Cloud Shell, as I don’t use any of these in the terminal I’m going to set their hidden value to true:

1"list": [
2 {
3 // Make changes here to the powershell.exe profile.
4 "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
5 "name": "Windows PowerShell",
6 "commandline": "powershell.exe",
7 "hidden": true
8 },
9 {
10 // Make changes here to the cmd.exe profile.
11 "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
12 "name": "Command Prompt",
13 "commandline": "cmd.exe",
14 "hidden": true
15 },
16 {
17 "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
18 "name": "Azure Cloud Shell",
19 "source": "Windows.Terminal.Azure",
20 "hidden": true
21 },
22]

Notice the guid that’s to identify the profile, and because I’ve hidden the current default one of PowerShell I’m going to update that so it opens in Ubuntu 20.04 each time, right at the top of the settings file is where I can set the default profile to use:

1{
2 "$schema": "https://aka.ms/terminal-profiles-schema",
3 "defaultProfile": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",

These default options on a profile can be extended, so when I pick a Debian shell I can have the colorScheme set to Campbell Powershell:

1{
2 "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
3 "hidden": false,
4 "name": "Debian",
5 "source": "Windows.Terminal.Wsl",
6 "colorScheme": "Campbell Powershell"
7}

Sweet!

Now popping open a Debian shell gives me that colour scheme!

It doesn’t stop there I can change the font size and font family as well if I want:

1{
2 "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
3 "hidden": false,
4 "name": "Debian",
5 "source": "Windows.Terminal.Wsl",
6 "fontSize": 8,
7 "fontFace": "Comic Sans MS",
8 "colorScheme": "Campbell Powershell"
9}

Maybe don’t use that font though! 😁

Background images

There’s an option to add background images to the terminal pane too!

For my use case I’ve added an Ubuntu image to the bottom of my Ubuntu instances and a Debian one to my Debian instance.

To add a background image I’ll first need to add the image to where the terminal can access it.

If you ever find reference to ms-appdata:///roaming for Windows Terminal, that’s translated into:

1%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState

I’ll use that location by copy pasting that into the run prompt (Windows key+r) of Windows and it opens the folder location.

In here is where I can add .png, .jpg and even .gif files!!

I tried .svg which doesn’t work.

Now I have some images available for the shell to access I can add them to the individual profiles for Debian and Ubuntu.

Here’s how it looks for Ubuntu:

1{
2 "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
3 "hidden": false,
4 "name": "Ubuntu-20.04",
5 "source": "Windows.Terminal.Wsl",
6 "backgroundImage": "ms-appdata:///roaming/ubuntu.png",
7 "backgroundImageStretchMode": "none",
8 "backgroundImageAlignment": "bottomRight",
9 "backgroundImageOpacity": 0.5
10},

There’s other options that are available, play around with them to get the disired effect, I’ve listed them here:

1"backgroundImageStretchMode": "fill",
2"backgroundImageStretchMode": "none",
3"backgroundImageStretchMode": "uniform",
4"backgroundImageStretchMode": "uniformToFill",
5
6"backgroundImageAlignment": "bottom",
7"backgroundImageAlignment": "bottomLeft",
8"backgroundImageAlignment": "bottomRight",
9"backgroundImageAlignment": "center",
10"backgroundImageAlignment": "left",
11"backgroundImageAlignment": "right",
12"backgroundImageAlignment": "top",
13"backgroundImageAlignment": "topLeft",
14"backgroundImageAlignment": "topRight",

Schemes

I’ve already covered schemes in theming, this is where I can dump all the themes I want to use for all the different profiles I can create in the profiles object!🔥

Currently in my settings.json this only holds the theme I pulled form Windows Terminal Themes but I could add all the themes from there here if I wanted, I’m happy with the one theme for now.

Keybindings

ℹ just to note that in the Windows Terminal Preview keybindings is replaced by actions.

Like I said at the top of this post I’m a massive keyboard shortcuts user so this section is for all the things I want to do with a couple of key strokes!

I’ll list out some of the default ones here:

  • Copy paste is set to: Ctrl+Shift+c and Ctrl+Shift+v respectively.
  • Find: Ctrl+Shift+f
  • Close open pane/tab: Ctrl+Shift+w

Now, for some shortcut keybindings I’ve added myself:

  • Split current pane: Ctrl+Alt+a
  • Duplicate current tab: Ctrl+Shift+d
  • Bump up font size: Ctrl+=
  • Bump down font size: Ctrl+-
  • Reset font size: Ctrl+0
  • Switch to next tab: Ctrl+pagedown
  • Switch to previous tab: Ctrl+pageup

These all go in the keybindings/actions section of the settings.json file, here’s how mine looks:

1({
2 "command": {
3 "action": "splitPane",
4 "split": "auto",
5 "splitMode": "duplicate"
6 },
7 "keys": "ctrl+alt+a"
8},
9{ "command": "duplicateTab", "keys": "ctrl+shift+d" },
10{
11 "command": { "action": "adjustFontSize", "delta": 1 },
12 "keys": "ctrl+="
13},
14{
15 "command": { "action": "adjustFontSize", "delta": -1 },
16 "keys": "ctrl+-"
17},
18{ "command": "resetFontSize", "keys": "ctrl+0" },
19{ "command": "nextTab", "keys": "ctrl+pagedown" },
20{ "command": "prevTab", "keys": "ctrl+pageup" })

Video detailing the process

As with most of my posts now I’ve added a video detailing the process…

That is for this one

One thing to watch out for is the Windows Terminal Preview which has all the latest features available on it which I’m going to switch to once I have finished writing this post!

Resources

Like I mentioned earlier the Microsoft docs are great there’s a ton of stuff available there I’ll also be keeping up to date on the Windows Command Line Blog.

Back to Top


Scott Spence

Built with Gatsby · Hosted on Vercel · 2021