[PR #15897] Allow inheriting env vars from wt again and other env var changes too #30772

Open
opened 2026-01-31 09:42:51 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/15897

State: closed
Merged: Yes


This PR is a few things:

  • part the first: Convert the compatibility.reloadEnvironmentVariables setting to a per-profile one.
    • The settings should migrate it from the user's old global place to the new one.
    • We also added it to "Profile>Advanced" while I was here.
  • Adds a new pair of commandline flags to new-tab and split-pane: --inheritEnvironment / --reloadEnvironment
    • On wt launch, bundle the entire environment that wt was spawned with, and put it into the Remoting.CommandlineArgs, and give them to the monarch (and ultimately, down to TerminalPage with the AppCommandlineArgs). DO THIS ALWAYS.
    • As a part of this, we’ll default to reloading if there’s no explicit commandline set, and inheriting if there is.
      • For example, wt -- cmd would inherit, and wt -p “Command Prompt” would reload.1
    • This is a little wacky, but we’re trying to separate out the intentions here:
      • wt -- cmd feels like “I want to run cmd.exe (in a terminal tab)”. That feels like the user would like environment variables from the calling process. They’re doing something more manual, so they get more refined control over it.
      • wt (or wt -p “Command Prompt”) is more like, “I want to run the Terminal (or, my Command Prompt profile) using whatever the Terminal would normally do”. So that feels more like a situation where it should just reload by default. (Of course, this will respect their settings here)

References and Relevant Issues

https://github.com/microsoft/terminal/issues/15496#issuecomment-1692450231 has more notes.

Detailed Description of the Pull Request / Additional comments

This is so VERY much plumbing. I'll try to leave comments in the interesting parts.

PR Checklist

  • This is not all of #15496. We're also going to do a -E foo=bar arg on top of this.
  • Tests added/passed
  • Schema updated

  1. In both these cases, plus the environment setting, of course. ↩︎

**Original Pull Request:** https://github.com/microsoft/terminal/pull/15897 **State:** closed **Merged:** Yes --- This PR is a few things: * part the first: Convert the `compatibility.reloadEnvironmentVariables` setting to a per-profile one. * The settings should migrate it from the user's old global place to the new one. * We also added it to "Profile>Advanced" while I was here. * Adds a new pair of commandline flags to `new-tab` and `split-pane`: `--inheritEnvironment` / `--reloadEnvironment` * On `wt` launch, bundle the entire environment that `wt` was spawned with, and put it into the `Remoting.CommandlineArgs`, and give them to the monarch (and ultimately, down to `TerminalPage` with the `AppCommandlineArgs`). DO THIS ALWAYS. * As a part of this, we’ll default to _reloading_ if there’s no explicit commandline set, and _inheriting_ if there is. * For example, `wt -- cmd` would inherit, and `wt -p “Command Prompt”` would reload.[^1] * This is a little wacky, but we’re trying to separate out the intentions here: * `wt -- cmd` feels like “I want to run cmd.exe (in a terminal tab)”. That feels like the user would _like_ environment variables from the calling process. They’re doing something more manual, so they get more refined control over it. * `wt` (or `wt -p “Command Prompt”`) is more like, “I want to run the Terminal (or, my Command Prompt profile) using whatever the Terminal would normally do”. So that feels more like a situation where it should just reload by default. (Of course, this will respect their settings here) ## References and Relevant Issues https://github.com/microsoft/terminal/issues/15496#issuecomment-1692450231 has more notes. ## Detailed Description of the Pull Request / Additional comments This is so VERY much plumbing. I'll try to leave comments in the interesting parts. ## PR Checklist - [x] This is not _all_ of #15496. We're also going to do a `-E foo=bar` arg on top of this. - [x] Tests added/passed - [x] Schema updated [^1]: In both these cases, plus the `environment` setting, of course.
claunia added the pull-request label 2026-01-31 09:42:51 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30772