TL;DR

  • In order to set a profile as the default profile you must enter the profile's GUID into the global "defaultProfile" setting.

  • GUIDS are not magical. They are not managed by some central authority. You don't have to ask anyone to generate or use a GUID. They're just numbers that are so big that their chances of clash are limited.

  • How to generate:

    • Powershell: [guid]::NewGuid()

    • Linux: uuidgen


I installed Windows Terminal today. I'd been reading a little about it and thought maybe now would be a good time to try it out.

I installed it through the Windows Store and started it up only to be immediately greeted by Powershell. I have a love/hate relationship with Powershell. It's not Powershell's fault, really. Powershell is very powerful. It's just not… Bash. But enough Powershell bashing (hee hee), for now.

Windows Terminal default terminals
[Fig.1 - Windows Terminal and the default terminals.]

Of course my immediate goal was to get Git bash in this thing posthaste. I found the Settings menu item (Ctrl-,) in the little drop-down menu in tab bar and clicked it. I was pleasantly surprised when it immediately popped a JSON file up in my VSCode. This is the profiles.json configuration file that allows you to configure everything in Windows Terminal.

There's something to be loved about structured configuration files like JSON and YAML. They are immediately comprehensible. There's nearly no need to search for documentation. The configuration itself is the documentation.

Here's how my profiles.json file looked when I started:

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles
        },
        "list":
        [
            {
                // Make changes here to the powershell.exe profile
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false
            },
            {
                // Make changes here to the cmd.exe profile
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "cmd",
                "commandline": "cmd.exe",
                "hidden": false
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            }
        ]
    },

    // Add custom color schemes to this array
    "schemes": [],

    // Add any keybinding overrides to this array.
    // To unbind a default keybinding, set the command to "unbound"
    "keybindings": []
}

This is pretty comprehensible, right? It is clear that all I needed to do was put a new profile object in the list array. I cheated a little and found this block specifically for Git Bash:

            {
                "name" : "Git Bash",
                "commandline" : "C:/Program Files/Git/bin/bash.exe",
                "icon" : "C:/Program Files/Git/mingw64/share/git/git-for-windows.ico",
                "startingDirectory" : "%USERPROFILE%",
            }

I put the above block into the file, saved it and viola! Bash! The only problem was that Powershell was still the default terminal. I want Bash as my default.

In order to set a profile as the default profile I must enter the profile's GUID into the global "defaultProfile" setting. But, the Git Bash profile that I found on the Internet didn't have a GUID property. Bash worked fine so the GUID wasn't absolutely required but without a GUID it would be impossible to set Bash as my default terminal. So, how or where do I get the GUID?

GUIDs

I didn't really know what a GUID was. I quickly looked it up and found that they are: Globally Unique IDentifiers. They are long, random numbers that can be used to name anything.

So, GUIDs are a way to give something a unique name in the universe. In fact, another name for GUID is UUID: Universally Unique IDentifier.

Now, the important thing to note about GUIDs is that there is no central managing authority that doles these unique identifiers out. These identifiers are generated independently using an algorithm that almost guarantees universal uniqueness - at least uniqueness among tens of trillions of other GUIDs.

Where's Git Bash's GUID?

So, what was the GUID for my Git Bash profile? Was it already defined somewhere?

I found that you could look into the Windows Registry (booo!) to find a GUID for your application but there was no GUID entry for Git Bash in my registry. Maybe I didn't look in the right place.

Then there was another reference that suggested going to new-guid.com to have a GUID generated for you. I obliged and copied the generated GUID into my Git Bash profile. Finally, I put the same GUID in the defaultProfile gobal property.

The result? Git Bash was now my default terminal!

Generating GUIDs

But that last step left me feeling weird. I didn't like going to a web site to have a GUID generated. But the experience indicated a couple things:

  1. GUIDs aren't intrinsically tied to your machine. There's nothing that makes a GUID only valid on your machine/setup. If a random web site can generate a GUID that does the job then there's nothing magical about them.
  2. GUIDs appeared to be trivial to generate. if this random website is doing it why couldn't I just generate them myself?

So, now on to the crux of the matter - and to an interesting irony in this post: We can generate our own GUIDs as easy as pie. And Powershell is probably the easiest way to do it on a Windows machine:

[guid]::NewGuid()

What results is a fresh GUID that you can use for anything - including your Windows Terminal profiles:

Guid
----
16f7d5ae-b0b1-466c-8a09-de6890669e30

Generating [GU]UIDs In Linux

Powershell is not the only way to generated GUIDs or UUIDs. And it might be better to say that, as usual, it can be done even easier in Bash than in Powershell:

uuidgen

Yeah, that easy. You might have to install a package to get uuidgen.

Conclusion

Generating GUIDs was the key to getting my Windows Terminal setup as I like it. All I needed to do was to take the mystery out of them.