Terminal: Expose the profile GUID to the environment (WT_PROFILE, WT_PROFILE_GUID?)

Created on 15 Nov 2019  路  12Comments  路  Source: microsoft/terminal

Description of the new feature/enhancement

We need a way to detect within a running terminal what profile instantiated it, so that we can make on-the-fly changes to the config (like change the background or font). The MSTerminalSetting is an example of that method.

Proposed technical implementation details (optional)

Provide the steps/api to PInvoke to get the profile guid based on the session guid. OR expose the session's profile guid to an environment variable like WT_PROFILE

Area-TerminalConnection Issue-Task Product-Terminal Resolution-Fix-Committed

Most helpful comment

@JustinGrote It's in the PR now as WT_PROFILE_ID and is in review. Will close when merged.

All 12 comments

I'd settle for setting WT_SESSION to the profile GUID instead of the seemingly pointless session GUID...

I'd settle for setting WT_SESSION to the profile GUID instead of the seemingly pointless session GUID...

It's possible to have the profile open in multiple places though, with different "sessions" -- I think this guid is keyed to the conpty connection itself, so it kinda needs to be unique globally.

@oising The main goal would be for a program running inside of windows terminal to be able to "find" what profile it is currently using, so that it can customize the settings.json for that profile in real-time.

As far as I understand there is no API to determine that using the WT_SESSION variable, unless you can enlighten me.

Invoke-TerminalGif as an example (currently I have to do a nasty workaround to make it work):
image

It doesn't have to replace WT_SESSION, it could instead be WT_PROFILE_GUID as mentioned.

I'd settle for setting WT_SESSION to the profile GUID instead of the seemingly pointless session GUID...

It's possible to have the profile open in multiple places though, with different "sessions" -- I think this guid is keyed to the conpty connection itself, so it kinda needs to be unique globally.

It "needs" to be unique for what? What can we _use_ a session guid _for_?

unique

WT_SESSION is an integral part of #766 and #961 that allows shells to cache and recover state as part of overall session restoration. It's analogous to TERMINAL_SESSION_ID on OS X.

@oising As the OP of this issue, the proposal you have here https://github.com/microsoft/terminal/pull/4852#issuecomment-597230418 would satisfy my requirement and this can be closed once merged

@JustinGrote It's in the PR now as WT_PROFILE_ID and is in review. Will close when merged.

But we won't get it until some time _after_ 1.0 - so the idea of using it in a script is basically DOA for months.

But we won't get it until some time _after_ 1.0 - so the idea of using it in a script is basically DOA for months.

I tried :/

It got merged after all - just had to remove the file path env vars for the moment :) /cc @Jaykul

Thanks @oising!

:tada:This issue was addressed in #4852, which has now been successfully released as Windows Terminal Preview v0.11.1121.0.:tada:

Handy links:

Was this page helpful?
0 / 5 - 0 ratings