GWSL-Source icon indicating copy to clipboard operation
GWSL-Source copied to clipboard

Windows Terminal opens with a wrong profile loaded

Open tpwo opened this issue 3 years ago • 1 comments
trafficstars

Hi, I changed the option in settings.json to use WT over the default terminal (i.e. "shell_gui": "wt"), but it was opening my default Windows Terminal profile rather than the WSL one.

I was able to find the root cause of my issue: my WSL distro had a different name compared to the WSL profile in Windows Terminal.

WSL distro name is Ubuntu-20.04:

> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2

Windows Terminal WSL profile name is Ubuntu:

{
    "guid": "<some ID>",
    "hidden": false,
    "name": "Ubuntu",
    "source": "Windows.Terminal.Wsl"
},

I see that you use this line to open wt:

subprocess.Popen(f'wt -p "{machine}"')

This command opens a given profile name according to MS Docs. It seems that it also opens a default profile when a name is not recognized, e.g. wt -p "foobar" will just open a default profile without any warning or error.

The solution on my side was to rename my WT profile, so it's the same as WSL distro name:

{
    "guid": "<some ID>",
    "hidden": false,
    "name": "Ubuntu-20.04",
    "source": "Windows.Terminal.Wsl"
},

What do you think about something like adding a new optional field to your settings.json, e.g. wt_profile_name, so you can specify a WT profile name if it is not the default one?

tpwo avatar Feb 07 '22 15:02 tpwo

I'll think about it. I don't have an update planned for a while, but I'll see how feasible it will be. I try to avoid updating the settings file because it can possibly corrupt things,

Pololot64 avatar Feb 07 '22 16:02 Pololot64