Expose the profile GUID to the environment (WT_PROFILE, WT_PROFILE_GUID?) #5019

Closed
opened 2026-01-31 00:03:05 +00:00 by claunia · 12 comments
Owner

Originally created by @JustinGrote on GitHub (Nov 15, 2019).

Originally assigned to: @oising on GitHub.

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

Originally created by @JustinGrote on GitHub (Nov 15, 2019). Originally assigned to: @oising on GitHub. <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # 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. <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # 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 <!-- A clear and concise description of what you want to happen. -->
Author
Owner

@Jaykul commented on GitHub (Feb 15, 2020):

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

@Jaykul commented on GitHub (Feb 15, 2020): I'd settle for setting WT_SESSION to the profile GUID instead of the seemingly pointless session GUID...
Author
Owner

@oising commented on GitHub (Mar 10, 2020):

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 commented on GitHub (Mar 10, 2020): > 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.
Author
Owner

@JustinGrote commented on GitHub (Mar 10, 2020):

@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.

@JustinGrote commented on GitHub (Mar 10, 2020): @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](https://user-images.githubusercontent.com/15258962/76343232-0a567280-62bd-11ea-8bed-4c5c44ac5034.png) It doesn't have to replace WT_SESSION, it could instead be WT_PROFILE_GUID as mentioned.
Author
Owner

@Jaykul commented on GitHub (Mar 10, 2020):

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?

@Jaykul commented on GitHub (Mar 10, 2020): > > 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_?
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 10, 2020):

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.

@DHowett-MSFT commented on GitHub (Mar 10, 2020): > 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.
Author
Owner

@JustinGrote commented on GitHub (Mar 10, 2020):

@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 commented on GitHub (Mar 10, 2020): @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
Author
Owner

@oising commented on GitHub (Mar 10, 2020):

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

@oising commented on GitHub (Mar 10, 2020): @JustinGrote It's in the PR now as `WT_PROFILE_ID` and is in review. Will close when merged.
Author
Owner

@Jaykul commented on GitHub (Apr 12, 2020):

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.

@Jaykul commented on GitHub (Apr 12, 2020): 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.
Author
Owner

@oising commented on GitHub (Apr 12, 2020):

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 :/

@oising commented on GitHub (Apr 12, 2020): > 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 :/
Author
Owner

@oising commented on GitHub (Apr 17, 2020):

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

@oising commented on GitHub (Apr 17, 2020): It got merged after all - just had to remove the file path env vars for the moment :) /cc @Jaykul
Author
Owner

@Jaykul commented on GitHub (Apr 18, 2020):

Thanks @oising!

@Jaykul commented on GitHub (Apr 18, 2020): Thanks @oising!
Author
Owner

@ghost commented on GitHub (Apr 22, 2020):

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

Handy links:

@ghost commented on GitHub (Apr 22, 2020): :tada:This issue was addressed in #4852, which has now been successfully released as `Windows Terminal Preview v0.11.1121.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v0.11.1121.0) * [Store Download](https://www.microsoft.com/store/apps/9n0dx20hk701?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5019