microsoft / terminal

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

Parameterizable dynamic profiles #5571

Open letmaik opened 4 years ago

letmaik commented 4 years ago

Description of the new feature/enhancement

Eventually the plugin system will allow to contribute new dynamic profiles. I think it would be useful if there was a way to parameterize dynamic profiles. Currently, the automatically provided "commandline" has to be overridden to customize anything. I think this breaks abstraction/layering/encapsulation/... and often there would be no need for it if dynamic profile providers become smarter. See examples below. If the community can't come up with more use cases then it's not worth the effort obviously. This issue is about collecting ideas and opinions.

Proposed technical implementation details (optional)

Instead of:

            {
                "guid": "{f9679c4b-7da6-409d-a372-86ebe9127f2a}",
                "commandline" : "powershell.exe -ExecutionPolicy ByPass -NoExit -Command \"& '%USERPROFILE%\\Miniconda3\\shell\\condabin\\conda-hook.ps1' ; conda activate tensorflow\"",
                "icon" : "%USERPROFILE%/Miniconda3/Menu/Iconleak-Atrous-PSConsole.ico",
                "name" : "Miniconda (tensorflow)"
            }

I'd like:

            {
                "guid": "{f9679c4b-7da6-409d-a372-86ebe9127f2a}",
                "source": "Continuum.Miniconda3",
                "name" : "Miniconda (tensorflow)",
                "options": {
                  "env": "tensorflow", // defaults to "base"
                  "shell": "powershell" // or "cmd"
                }
            }

Instead of:

            {
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore",
                "commandline": "C:\\Program Files\\PowerShell\\6\\pwsh.exe --NoLogo"  
            }

I'd like:

            {
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore",
                "options": {
                  "nologo": true
                }
            }
jdhitsolutions commented 4 years ago

I agree it might be nice to separate command-line arguments, from the command line. Although I'd probably opt for something like:

  {
                "commandline": "powershell.exe",
                "arguments" : "-nologo -noprofile",
                "guid": "{ca3da2bd-de18-40f7-9fc6-234345d1e89f}",
                "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
                "name": "Windows PowerShell No Profile",
                "tabTitle": "PS No Profile",
                "useAcrylic": true
            }

Taking this a step further I can envision a scenario launching a profile with WT.exe and specifying dynamic arguments.

DHowett-MSFT commented 4 years ago

Yeah, we should definitely have a story for this. I'm a bit scarred by Docker's ENTRYPOINT versus CMD nonsense, but it makes some amount of sense. If you set the entrypoint/command properly, docker run containerapp becomes a stand-in for app, because it passes all of its arguments to app internally. It makes sense.

It'll take work to comport all these things, and no small amount of design (to make sure it keeps working for everyone), but I love the idea of wt -p PSCore -nologo test.ps1.

letmaik commented 4 years ago

Yeah, I agree with you guys that just using extra arguments might be more sensible. And if for some reason this wouldn't work because the thing to customize appears in weird places, then one could always write a wrapper script that makes it nice again.

TBBle commented 3 years ago

Just came across another user-story for this (or at least, I think it's this) which is customising parts of the profile other than the command line.

Per https://github.com/microsoft/terminal/issues/1669#issuecomment-830732471, my current full-coverage MSYS2 set of profiles look like

      {
        "guid": "{c1372a71-8d9f-49d7-99db-8cb284c50b98}",
        //"commandline": "\"C:/msys64/msys2_shell.cmd\" -defterm -no-start -msys2",
        "commandline": "C:/msys64/usr/bin/env.exe MSYS='enable_pcon winsymlinks:nativestrict' CHERE_INVOKING=1 MSYSTEM=MSYS /bin/bash --login",
        "icon": "C:/msys64/msys2.ico",
        "name": "MSYS2 MSYS"
      },
      {
        "guid": "{2367860f-e6b6-4e91-821a-287e0cceee71}",
        //"commandline": "\"C:/msys64/msys2_shell.cmd\" -defterm -no-start -mingw64",
        "commandline": "C:/msys64/usr/bin/env.exe MSYS='enable_pcon winsymlinks:nativestrict' CHERE_INVOKING=1 MSYSTEM=MINGW64 /bin/bash --login",
        "icon": "C:/msys64/mingw64.ico",
        "name": "MSYS2 MinGW 64-bit"
      },
      {
        "guid": "{098bcacf-f271-4b79-b6c3-315bb4240e54}",
        //"commandline": "\"C:/msys64/msys2_shell.cmd\" -defterm -no-start -mingw32",
        "commandline": "C:/msys64/usr/bin/env.exe MSYS='enable_pcon winsymlinks:nativestrict' CHERE_INVOKING=1 MSYSTEM=MINGW32 /bin/bash --login",
        "icon": "C:/msys64/mingw32.ico",
        "name": "MSYS2 MinGW 32-bit"
      },
      {
        "guid": "{20ca76e4-8d6f-4d37-8468-dbf02385dd18}",
        //"commandline": "\"C:/msys64/msys2_shell.cmd\" -defterm -no-start -ucrt64",
        "commandline": "C:/msys64/usr/bin/env.exe MSYS='enable_pcon winsymlinks:nativestrict' CHERE_INVOKING=1 MSYSTEM=UCRT64 /bin/bash --login",
        "icon": "C:/msys64/ucrt64.ico",
        "name": "MSYS2 UCRT 64-bit"
      },
      {
        "guid": "{87536769-301c-4fee-89c9-c1aa8950e471}",
        //"commandline": "\"C:/msys64/msys2_shell.cmd\" -defterm -no-start -clang64",
        "commandline": "C:/msys64/usr/bin/env.exe MSYS='enable_pcon winsymlinks:nativestrict' CHERE_INVOKING=1 MSYSTEM=CLANG64 /bin/bash --login",
        "icon": "C:/msys64/clang64.ico",
        "name": "MSYS2 Clang 64-bit"
      },

Apart from the name, they are all varying only in the value of the MSYSTEM env-var (included in the icon name), so once we have a dynamic profile generator for MSYS2, it'd be nice to be able to do something like

            {
                "guid": "{87536769-301c-4fee-89c9-c1aa8950e471}",
                "name": "MSYS2 Clang 64-bit",
                "source": "Some.Plugin.Profiles.MSYS2",
                "options": {
                  "msystem": "clang64" # Default is msys2
                }
            }

although in this case it's likely to be adding profiles (you would still keep the msys2 profile around for pacman, I expect), so given it's a closed set, perhaps this is not actually a good use-case for customisation, as the generator could generate all the profiles, and users can just enable/disable as they see fit.

The MSYS env-var might be a good use-case for customisation though, since that's used to hold a bunch of toggles. A dynamic profile generator (and given #2785 so we don't need to use env to set env-vars, which won't work with the "append command line args" proposal because that will affect the program's arguments, not env's arguments) might want to honour the <MSYSTEM>.ini file though, rather than exposing these via Windows Terminal.

So yeah, MSYS2 wouldn't need the functionality here, but it does illustrate a non-command-line use-case.