microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
93.92k stars 8.12k forks source link

WSL import profile folders setting #17262

Closed Firehawke closed 2 weeks ago

Firehawke commented 2 weeks ago

Description of the new feature/enhancement

Since Windows Terminal now supports setting up folders for profile groups, a setting to put WSL instances in a folder of your choice by default would be useful.

This came about when I started playing with nixos as a WSL2 instance; Windows Terminal found it by default as it should, but dumped it in the root folder so I'd have to edit the json to put it into the Linux folder where I keep my other WSL instances.

Proposed technical implementation details (optional)

A config setting in the JSON (and eventually in the UI as well, I know that's long-term as folders have almost no UI accessibility right now) to tell WT to put WSL2 imports in a specific folder by default. It's fine if the default starts off as the root as it is now; I can change it as needed after that point.

DHowett commented 2 weeks ago

Thanks for the request! You can sort of do this already, by using a matchProfiles entry in the new tab menu (docs).

Here's what mine looks like:

"newTabMenu": 
[
    {
        "type": "remainingProfiles"
    },
    {
        "allowEmpty": false,
        "entries": 
        [
            {
                "commandline": null,
                "name": null,
                "source": "Windows.Terminal.Wsl",
                "type": "matchProfiles"
            }
        ],
        "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
        "inline": "never",
        "name": "WSL",
        "type": "folder"
    }
],

In brief: it's two toplevel menu items, one that says "all unclaimed profiles go in the root" and one that says "now put some WSL profiles in a folder called WSL". All WSL profiles will go into the folder, and all non-WSL profiles will go into the root.

You can minimize it down to...

"newTabMenu": [
    { "type": "remainingProfiles" },
    {
        "entries": [ { "source": "Windows.Terminal.Wsl", "type": "matchProfiles" } ],
        "name": "WSL",
        "type": "folder"
    }
],

It looks like this at runtime (for me):

Image

(The ubuntu profile doesn't report as WSL, because Canonical Ltd created a new custom entry for it - you can use as many matchProfiles entries as you need in a menu, though, to cover everything you want.)

Does that help?

DHowett commented 2 weeks ago

FWIW, my actual new tab menu config looks like this:

Dustin's real new tab menu customization ```json "newTabMenu": [ { "type": "remainingProfiles" }, { "allowEmpty": false, "entries": [ { "commandline": null, "name": null, "source": "Windows.Terminal.PowershellCore", "type": "matchProfiles" } ], "icon": "ms-appx:///ProfileIcons/pwsh-preview.png", "inline": "never", "name": "PowerShell", "type": "folder" }, { "allowEmpty": false, "entries": [ { "commandline": null, "name": null, "source": "Windows.Terminal.VisualStudio", "type": "matchProfiles" }, { "profile": "{f795dd7e-af72-4ac5-befc-1676ae18cfb0}", "type": "profile" } ], "icon": "ms-appx:///ProfileIcons/pwsh-preview.png", "inline": "never", "name": "VS", "type": "folder" }, { "allowEmpty": false, "entries": [ { "commandline": null, "name": null, "source": "Windows.Terminal.Wsl", "type": "matchProfiles" }, { "commandline": null, "name": null, "source": "CanonicalGroupLimited.Ubuntu20.04LTS_79rhkp1fndgsc", "type": "matchProfiles" } ], "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", "inline": "never", "name": "WSL", "type": "folder" } ], ``` ![Image](https://github.com/microsoft/terminal/assets/189190/33f38bf6-942d-4362-8f71-865e12f80ef7)
Firehawke commented 2 weeks ago

At least for now that seems to be the best option we have. Thanks.