Windows Terminal Configuration

Windows Terminal Configuration

The good old days

Until Windows-based operating systems came along, almost every OS was command-line based. DOS, Unix (not Linux, as it didn’t exist), OS/400, System 36, TI990, everything. For years, I used those command lines as there was nothing else.

Even when Windows came into being, I still used the command line for many day-to-day jobs. When Windows 95 came along, it wasn’t necessary to use the command line anywhere near as much, so, over time, I virtually stopped using it.

Today

Over the last few years, as I have started using Linux, my use of the command line has increased to the point where I use it daily for one thing or another. On Windows machines, I continued to use the DOS prompt, but over the last couple of years, I moved over to Powershell. With the introduction of WSL in Windows, this has become a great environment to do virtually everything I need.

With the introduction of Windows 11, Windows Terminal has become my standard Terminal. It is so much more configurable that I just live there!

Basic Setup

The default Windows 11 Terminal is fine for most users. Introducing Multi-Tab functionality and split windows makes it far easier to do multiple things simultaneously without many open windows.

Currently, my terminal looks like this: –

image-89-1024x272 Windows Terminal Configuration

Note that this Powershell version is installed via the Windows Store App. As I write this post, it is not part of Windows 11. Also, note that I am using ‘Oh My Posh’ to give me some helpful information regarding what system I am connected to, the user ID I am connected with and where I am in the file system – more on this later.

Windows 11 Terminal can be configured far more than previous versions. The screenshot below shows the icon in the title bar where you can select new tabs – each can be a different type of terminal – and where you access settings: –

image-90 Windows Terminal Configuration

Installing the Powershell version from the Windows Store appears in that list without you having to do anything else.

The settings option in the dropdown list has many options to tailor your environment to your liking. You can either click on the icon and select Settings, or you can simply hit CTRL-A. I find this shortcut the easiest option. The screenshot below shows the settings page: –

image-91-1024x606 Windows Terminal Configuration

In the Startup tab, I set the Default Profile to the new version of Powershell. I usually leave the other settings on that tab as the defaults.

On the Appearance tab, I change the Application Theme to Dark mode. Again, I usually leave the other settings as defaults.

image-92-1024x450 Windows Terminal Configuration

The Colour Schemes tab lets you change the colours you want within the terminal. I keep swapping and changing these but usually resort back to the default colours for the Dark theme, as shown here: –

image-93 Windows Terminal Configuration

The Actions tab lets you edit or add shortcuts of one sort or another, as can be seen below: –

image-94-915x1024 Windows Terminal Configuration

The Defaults tab has some handy settings in it, as shown below: –

image-95-1024x815 Windows Terminal Configuration

The Starting Directory can be helpful if you have a folder on your machine with various tools that aren’t in your path. I have a USB stick with a general-purpose folder with many command-line programs. This allows me to configure that folder as my default. I don’t use this feature often, but having it when needed is nice.

At the bottom of the defaults page is a section for additional settings. The Appearance section has these extra options: –

image-96-1024x766 Windows Terminal Configuration

The Retro Terminal Effects setting is fun. If you enable it, your terminal looks like this: –

image-97-1024x643 Windows Terminal Configuration

It messes with my eyes, but you might like it.

A great feature of the settings panel is that you can independently change the defaults and appearance of each type of terminal. I find this useful when I am working on different systems at the same time. I can change my Bash settings to know I am on a Linux machine because of a diverse coloured background.

Another cool feature of the Settings section is the little cog at the bottom, as can be seen here: –

image-98 Windows Terminal Configuration

This allows you to edit the JSON file containing the settings. It looks like this: –

{
    "$help": "https://aka.ms/terminal-documentation",
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": 
    [
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ],
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
    "newTabMenu": 
    [
        {
            "type": "remainingProfiles"
        }
    ],
    "profiles": 
    {
        "defaults": 
        {
            "experimental.retroTerminalEffect": false,
            "opacity": 60,
            "useAcrylic": true,
            "useAtlasEngine": true
        },
        "list": 
        [
            {
                "experimental.retroTerminalEffect": false,
                "font": 
                {
                    "face": "CaskaydiaCove Nerd Font"
                },
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore"
            },
            {
                "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": true,
                "name": "Windows PowerShell"
            },
            {
                "commandline": "%SystemRoot%\\System32\\cmd.exe",
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "Command Prompt"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{1bf3c938-7e31-575a-8f1e-5601b7360a2c}",
                "hidden": false,
                "name": "Developer Command Prompt for VS 2022",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{a8069d7d-f4bc-5c59-b88f-9b833458e966}",
                "hidden": false,
                "name": "Developer PowerShell for VS 2022",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
                "hidden": false,
                "name": "Git Bash",
                "source": "Git"
            },
            {
                "guid": "{16208362-94fc-5b1f-a491-5b2624d5ab56}",
                "hidden": true,
                "name": "Visual Studio Debug Console",
                "source": "VSDebugConsole"
            }
        ]
    },
    "schemes": 
    [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#012456",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell Powershell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#282C34",
            "black": "#282C34",
            "blue": "#61AFEF",
            "brightBlack": "#5A6374",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B6C2",
            "brightGreen": "#98C379",
            "brightPurple": "#C678DD",
            "brightRed": "#E06C75",
            "brightWhite": "#DCDFE4",
            "brightYellow": "#E5C07B",
            "cursorColor": "#FFFFFF",
            "cyan": "#56B6C2",
            "foreground": "#DCDFE4",
            "green": "#98C379",
            "name": "One Half Dark",
            "purple": "#C678DD",
            "red": "#E06C75",
            "selectionBackground": "#FFFFFF",
            "white": "#DCDFE4",
            "yellow": "#E5C07B"
        },
        {
            "background": "#FAFAFA",
            "black": "#383A42",
            "blue": "#0184BC",
            "brightBlack": "#4F525D",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B5C1",
            "brightGreen": "#98C379",
            "brightPurple": "#C577DD",
            "brightRed": "#DF6C75",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#E4C07A",
            "cursorColor": "#4F525D",
            "cyan": "#0997B3",
            "foreground": "#383A42",
            "green": "#50A14F",
            "name": "One Half Light",
            "purple": "#A626A4",
            "red": "#E45649",
            "selectionBackground": "#FFFFFF",
            "white": "#FAFAFA",
            "yellow": "#C18301"
        },
        {
            "background": "#002B36",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#FFFFFF",
            "cyan": "#2AA198",
            "foreground": "#839496",
            "green": "#859900",
            "name": "Solarized Dark",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#FDF6E3",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#002B36",
            "cyan": "#2AA198",
            "foreground": "#657B83",
            "green": "#859900",
            "name": "Solarized Light",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#D3D7CF",
            "green": "#4E9A06",
            "name": "Tango Dark",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#FFFFFF",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#000000",
            "cyan": "#06989A",
            "foreground": "#555753",
            "green": "#4E9A06",
            "name": "Tango Light",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#000080",
            "brightBlack": "#808080",
            "brightBlue": "#0000FF",
            "brightCyan": "#00FFFF",
            "brightGreen": "#00FF00",
            "brightPurple": "#FF00FF",
            "brightRed": "#FF0000",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#008080",
            "foreground": "#C0C0C0",
            "green": "#008000",
            "name": "Vintage",
            "purple": "#800080",
            "red": "#800000",
            "selectionBackground": "#FFFFFF",
            "white": "#C0C0C0",
            "yellow": "#808000"
        }
    ],
    "themes": []
}

You can edit any setting in the file and even move blocks of setting up and down. This changes the sequence of the terminal types in the dropdown list in Terminal. If you save this file somewhere, you can use the same settings on multiple machines. I like to put it into source control, too.

If you download the cross-platform version of Powershell like I did, you can disable the default version of Powershell by changing the ‘hidden’ flag on the old item like this: –

 {
                "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": true,
                "name": "Windows PowerShell"
            },

Configuring Powershell Fonts

As you can see in the screenshots above, you can use many settings to make Terminal look the way you want, but we can go much further. As you will have seen in the first screenshot above, which shows what my Terminal looks like, my prompt contains much more than the normal Powershell prompt. This is courtesy of a utility called ‘oh-my-posh’.

This can be found here: – https://github.com/JanDeDobbeleer/oh-my-posh/

But the best place to start is https://ohmyposh.dev

Before you install this utility, it is essential to update your fonts. OhMyPosh has a few glyphs within the prompt, and these need to be on your machine before things look right.

To do this, you must visit this site: – https://www.nerdfonts.com/font-downloads and download a font containing the glyphs. I use a font called Caskaydia Nerd ont. Ultimately, I downloaded and installed all of them because I wanted to play around with different fonts. This obviously takes up more space on your machine, but it allows you to change them until you are happy – you can then delete the ones you don’t want.

You can install the fonts by copying them into your fonts folder under c:\Windows or by right-clicking on each font and clicking Install.

Having downloaded and installed the fonts, I set my default font to Caskaydia Nern Font for Powershell in the settings section of Terminal.

Installing OhMyPosh

This is a simple process and only needs one line: –

winget install JanDeDobbeleer.OhMyPosh -s winget

This installs the executable command and a set of themes – there are some great themes available – just look through them and decide on a favourite.

OMP installs an additional Powershell command that displays all the themes. This is: –

Get-PoshThemes

It displays each theme like this: –

image-99-1024x599 Windows Terminal Configuration

Each of these theme files is just another JSON file. The colours and settings defined in the JSON define how the prompt looks and what it contains.

Once you have chosen your preferred theme, copy that JSON into your own file or configure OMP to point to one of the theme files on OMP’s theme folder on GitHub.

Once this is installed, you need to restart your Terminal. This is because the installer changes your $PATH.

Configuring the Shell

At this point, you need to configure your shell to use the utility. This is easy. There are two steps. First, create a configuration file to hold your ‘OhMyPosh’ configuration. I created a folder called ‘posh’ in my user GIT folder.

To configure OMP, create a JSON file with the definitions of the sections you want in the prompt. My file is stf.json, and I store it in the ‘posh’ folder I defined earlier. My file looks like this and was initially copied from the JanDeDobbeleer theme: –

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "segments": [
        {
          "foreground": "#3A86FF",
          "style": "plain",
          "template": "{{ if .WSL }}WSL at {{ end }}{{.Icon}} ",
          "type": "os"
        },
        {
          "background": "#242424",
          "foreground": "#f1184c",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " {{ .UserName }}",
          "type": "session"
        },
        {
          "background": "#242424",
          "foreground": "#f1184c",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": "- root \uf0e7",
          "type": "root"
        },
        {
          "background": "#242424",
          "foreground": "#FFBB00",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "time_format": "2006-01-02 15:04:05"
          },
          "style": "powerline",
          "template": "{{ .CurrentDate | date .Format }} ",
          "type": "time"
        },
        {
          "background": "#242424",
          "foreground": "#33DD2D",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "folder_separator_icon": "/",
            "style": "full"
          },
          "style": "powerline",
          "template": "\ue5ff {{ .PWD }} ",
          "type": "path"
        },
        {
          "background": "#242424",
          "foreground": "#3A86FF",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "fetch_stash_count": true,
            "fetch_upstream_icon": true
          },
          "style": "powerline",
          "template": "{{ .UpstreamIcon }}{{ .HEAD }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ",
          "type": "git"
        },
        {
          "background": "#33DD2D",
          "background_templates": [
            "{{ if gt .Code 0 }}#f1184c{{ end }}"
          ],
          "foreground": "#242424",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "always_enabled": true
          },
          "style": "powerline",
          "template": " \uea6c ",
          "type": "status"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "foreground": "#f1184c",
          "style": "plain",
          "template": "\u279c ",
          "type": "text"
        }
      ],
      "type": "prompt"
    }
  ],
  "version": 2
}

This file can have many sections, and you need to look at the OMP for options. There

Then you edit the Powershell User Profile file by running this command for Powershell: –

notepad $PROFILE

If this command throws an error, you just need to create the profile file like this: –

New-Item -Path $PROFILE -Type File -Force

The only line that needs to be added to this file is a command that runs OMP and sets the JSON file containing the sections and the theme you want to use. My file looks like this: –

oh-my-posh --init --shell pwsh --config c:\users\stf\git\posh\stf.json | Invoke-Expression

You should refer to the OMP documentation for the available. This command line tells OMP to initialise itself in Powershell using my JSON file.

More Powershell goodness

As we created a Powershell Profile earlier, we can add more functionality by adding lines.

Depending on the functionality you want to use, you may need to install additional modules into PowerShell using an Install-Module command. One such instance is the PSReadLine command used below. For that, in PowerShell, running under and Administrator, run the command: –

Install-Module PSReadLine

I only add a couple of lines to my PowerShell profile, and these are: –

Set-PSReadLineOption -PredictionViewStyle ListView
Set-Alias -name k -Value kubectl

The first line gives you command history like this: –

image-100-1024x255 Windows Terminal Configuration

Once the list of commands is displayed, you can move up and down using the arrow keys.

The other line is a simple PowerShell Alias for the ‘kubectl’ command I use to configure and monitor Kubernetes. Instead of having to type the word kubectl each time, I just type ‘k’ like this: –

image-101-1024x230 Windows Terminal Configuration

Summary

If you spend time using Terminal and Powershell, you really should look to make your time with them as efficient as possible. The details above give you a great-looking environment.

Stephen

Hi, my name is Stephen Finchett. I have been a software engineer for over 30 years and worked on complex, business critical, multi-user systems for all of my career. For the last 15 years, I have been concentrating on web based solutions using the Microsoft Stack including ASP.Net, C#, TypeScript, SQL Server and running everything at scale within Kubernetes.