custom environment variables in settings.json map #17833

Closed
opened 2026-01-31 05:55:50 +00:00 by claunia · 4 comments
Owner

Originally created by @WanderLanz on GitHub (Jun 30, 2022).

Description of the new feature/enhancement

Adding a new settings.json mapping for extra environment variables injected by conpty initialization,
allowing for user-set environment variables to be handled directly by WindowsTerminal and passed to children as WT_SESSION and WT_PROFILE_ID are.

As it stands, using SETX to load custom environment variables into every terminal child invites cloberring of vars like WSLENV, since WindowsTerminal manually appends and prepends WT_SESSION and WT_PROIFLE_ID to WSLENV.

...
This stems from #7130 and modules wishing to find the equivalent of "$env:WT_SETTINGS". I could not find a similar request, but I apologize in advance if this is a superfluous suggestion.

Proposed technical implementation details (optional)

Using internal "_environment" in ConptyConnection.cpp as external settings.json map "environment", if possible, since "_environment" seems to already handle injecting arbitrary* environment variables.

Originally created by @WanderLanz on GitHub (Jun 30, 2022). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 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 <!-- 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). --> Adding a new settings.json mapping for extra environment variables injected by conpty initialization, allowing for user-set environment variables to be handled directly by WindowsTerminal and passed to children as WT_SESSION and WT_PROFILE_ID are. As it stands, using SETX to load custom environment variables into every terminal child invites cloberring of vars like WSLENV, since WindowsTerminal manually appends and prepends WT_SESSION and WT_PROIFLE_ID to WSLENV. ... This stems from #7130 and modules wishing to find the equivalent of "$env:WT_SETTINGS". I could not find a similar request, but I apologize in advance if this is a superfluous suggestion. # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. --> Using internal "_environment" in ConptyConnection.cpp as external settings.json map "environment", if possible, since "_environment" seems to already handle injecting arbitrary* environment variables.
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-Fix labels 2026-01-31 05:55:50 +00:00
Author
Owner

@j4james commented on GitHub (Jul 2, 2022):

If I've understood you correctly, I think this may be a duplicate of #2785.

@j4james commented on GitHub (Jul 2, 2022): If I've understood you correctly, I think this may be a duplicate of #2785.
Author
Owner

@WanderLanz commented on GitHub (Jul 3, 2022):

@j4james Yes it would seem I might have done something unnecessary!

My suggestion is specifically referring to global environment variables for every profile rather than profile-by-profile, because the way ConptyConnection.cpp adds both WT_SESSION and WT_PROFILE_ID made it seem like it would be easier.

I feel like I should leave this open for now unless #9287 also implements a global "environment" or the profile-by-profile solution is as far as custom environments directly from settings.json will go.

Feel free to close this if you feel it is a duplicate, this is by no means a first-class priority.

@WanderLanz commented on GitHub (Jul 3, 2022): @j4james Yes it would seem I might have done something unnecessary! My suggestion is specifically referring to global environment variables for every profile rather than profile-by-profile, because the way ConptyConnection.cpp adds both WT_SESSION and WT_PROFILE_ID made it seem like it would be easier. I feel like I should leave this open for now unless #9287 also implements a global "environment" or the profile-by-profile solution is as far as custom environments directly from settings.json will go. Feel free to close this if you feel it is a duplicate, this is by no means a first-class priority.
Author
Owner

@j4james commented on GitHub (Jul 3, 2022):

I haven't looked at PR #9287 in detail, but I think your use-case should be covered by the "Defaults" profile. If you set an environment variable in "Defaults", I assume that would be the equivalent of a "global" environment variable that would apply to all profiles. That's the way other profile settings work.

@j4james commented on GitHub (Jul 3, 2022): I haven't looked at PR #9287 in detail, but I think your use-case should be covered by the "Defaults" profile. If you set an environment variable in "Defaults", I assume that would be the equivalent of a "global" environment variable that would apply to all profiles. That's the way other profile settings work.
Author
Owner

@WanderLanz commented on GitHub (Jul 4, 2022):

@j4james Thank you for the clarification, I'll go ahead and close this.

@WanderLanz commented on GitHub (Jul 4, 2022): @j4james Thank you for the clarification, I'll go ahead and close this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17833