3

I've just installed WSL2 and am using the Windows Terminal on Win10 1909 (18363.1256). I'm trying to set up 2 different profiles, one that launches a local WSL2 Ubuntu shell, and one that launches another WSL2 shell that will automatically ssh to a specific host.

The local one works great, shows up without an issue, however I can't seem to get my 2nd profile to show up in the list of profiles.

My settings.json looks like this:

"profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
            "colorScheme": "One Half Dark",
            "fontFace": "JetbrainsMono NF",
            "fontSize": 11
        },
        "list":
        [
            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl",
                "startingDirectory": "//wsl$/Ubuntu/home/sensanaty",
                "tabTitle": "WSL2"
            },
            {
                "guid": "{15c5814b-7ed1-4cec-bc64-d165274958fa}",
                "hidden": false,
                "name": "External Host",
                "source": "Windows.Terminal.Wsl",
                "commandline": "ssh example@123.456.7.89",
                "tabTitle": "External Host"
            },
        ]
    },

With the above, I only get the Ubuntu profile in my list

enter image description here

I thought maybe it was the guid generated or something, but I just did a simple uuidgen and pasted it into the json so it shouldn't really be causing any issues there. I've also obviously tried restarting my system, to no avail. The default profiles show up fine if I disable the option to stop auto-generating them, as well.

Any clue as to what might help me out?

Sensanaty
  • 894
  • 1
  • 12
  • 35

3 Answers3

4

The 'source' attribute is for dynamically generated profiles, for which WSL will create one for each instance installed. You can't control the command line for these dynamically generated profiles. What you need is for your new profile to extend the command line to tell Terminal to use WSL. Remove the 'source' attribute entirely, so that your new profile is static.

In your case, that should be ...

            {
                "guid": "{15c5814b-7ed1-4cec-bc64-d165274958fa}",
                "hidden": false,
                "name": "External Host",
                //"source": "Windows.Terminal.Wsl",
                "commandline": "wsl.exe ssh example@123.456.7.89",
                "tabTitle": "External Host"
            }//, 

As bwolfbarn mentioned, you should also ditch that trailing comma if it really comes at the end of the "list" block.

Here are a few lines from mine as additional examples as well ...

            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "name": "Ubuntu 20.04 WSL2 tmux",
                //"source": "Windows.Terminal.Wsl",
                "commandline": "wsl.exe -d Ubuntu -e sh -c \"/usr/bin/tmux has-session -t main 2>/dev/null && /usr/bin/tmux attach-session -d -t main || /usr/bin/tmux -2 new-session -t main -s main -c ${HOME}\"",
                "cursorShape": "filledBox"
            },
            {
                "guid": "{4e04fa7e-76c7-4746-a322-a227e70dde6c}",
                "hidden": false,
                "name": "Ubuntu 20.04 WSL1 tmux",
                //"commandline": "wsl.exe -d Ubuntu20.04_WSL1",
                "commandline": "wsl.exe -d Ubuntu20.04_WSL1 -e sh -c \"/usr/bin/tmux has-session -t main 2>/dev/null && /usr/bin/tmux attach-session -d -t main || /usr/bin/tmux -2 new-session -t main -s main -c ${HOME}\"",
                "cursorShape": "filledBox"
            }

Note that you could, I believe, use "wsl.exe -e" (a.k.a. --execute), but it's not really necessary in your case.

NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70
2

If you want to see your "source": "Windows.Terminal.Wsl" in Windows Terminal Menu it must exist in the registry [HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\{UUID}] (The registry UUID is not related to Windows Terminal UUID).

This registry entry can be created by running "wsl --import" or by cloning existing entry (if you are comfortable messing with the registry).

If you still don't see your profile after confirming that the registry entry exists, remove all entries for "generatedProfiles" in state.json file located in the same folder as settings.json. This will force Windows Terminal to update state.json. If you generated Windows Terminal profile UUID yourself, it may ignore it and create its own one. In this case you will see duplicate entries for the profile in settings.json. Remove the ones that were generated manually, and leave the one generated by the terminal.

Konstantin Glukhov
  • 1,898
  • 3
  • 18
  • 25
  • Please re-read the question. This does not attempt to answer the question of how to create a profile for `ssh`, which is what was asked. – NotTheDr01ds Oct 19 '21 at 13:29
  • Maybe you should re-read the question. It is in plain English: "Windows Terminal profile not showing up". I provided one of the solution on making it "showing up". – Konstantin Glukhov Oct 20 '21 at 06:00
  • You answered the question title, without actually reading the question ... – NotTheDr01ds Oct 20 '21 at 11:40
  • That what most people do: search for help by title, not by context. What the point of having Title different from the Context? Title should reflect the context, and context should only expand on the title. Also I re-read the question carefully and it matches the title, I don't know what's your problem - obviously you don't understand my answer. – Konstantin Glukhov Oct 21 '21 at 06:10
1

At least the last comma should be removed (I commented it in your example) as the element "External Host" is the last of the list.

 [
            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl",
                "startingDirectory": "//wsl$/Ubuntu/home/sensanaty",
                "tabTitle": "WSL2"
            },
            {
                "guid": "{15c5814b-7ed1-4cec-bc64-d165274958fa}",
                "hidden": false,
                "name": "External Host",
                "source": "Windows.Terminal.Wsl",
                "commandline": "ssh example@123.456.7.89",
                "tabTitle": "External Host"
            }//, 
        ]
bwolfbarn
  • 53
  • 6