Open a new pane with the environment vars of the parent #5980

Open
opened 2026-01-31 00:27:00 +00:00 by claunia · 11 comments
Owner

Originally created by @zadjii-msft on GitHub (Jan 16, 2020).

Just chiming in;

_ (profile,working dir, environment var, etc)._

Anything about the actual process on the other end is, in the general case, impossible to replicate. The connected process could be ssh.exe, whose environment variables and working directory have no bearing on the detectable environment and working directory from the terminal side. The same actually, weirdly enough, applies to WSL. It doesn't use "working directory" and it doesn't expose its environment variables to interested Windows processes in any way.
Powershell doesn't even set the current working directory, so its directory can't be detected (!) either.

Was interested in this but seems like it's not going to happen. Just curious if something like 'start' in cmd can't work in terminal. Is this the case ?

@zadjii-msft I'm trying to clone the current terminal into a new pane. I need the same environment var's etc carried over similar to how 'start' does it in cmd. I know it isn't currently possible but is there a temporary workaround?

Originally posted by @Surya-06 in https://github.com/microsoft/terminal/issues/1756#issuecomment-575134471

Originally created by @zadjii-msft on GitHub (Jan 16, 2020). > > > Just chiming in; > > > _ (profile,working dir, environment var, etc)._ > > > > > > Anything about the _actual process_ on the other end is, in the general case, impossible to replicate. The connected process could be `ssh.exe`, whose environment variables and working directory have no bearing on the detectable environment and working directory from the terminal side. The same actually, weirdly enough, applies to WSL. It doesn't use "working directory" and it doesn't expose its environment variables to interested Windows processes in any way. > > Powershell doesn't even _set_ the current working directory, so its directory can't be detected (!) either. > > Was interested in this but seems like it's not going to happen. Just curious if something like 'start' in cmd can't work in terminal. Is this the case ? > @zadjii-msft I'm trying to clone the current terminal into a new pane. I need the same environment var's etc carried over similar to how 'start' does it in cmd. I know it isn't currently possible but is there a temporary workaround? _Originally posted by @Surya-06 in https://github.com/microsoft/terminal/issues/1756#issuecomment-575134471_
claunia added the Area-SettingsIssue-TaskPriority-3Product-Terminal labels 2026-01-31 00:27:01 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Jan 23, 2020):

I'm pulling Triage, but this might not be possible.

@DHowett-MSFT commented on GitHub (Jan 23, 2020): I'm pulling Triage, but this might not be possible.
Author
Owner

@surya-prakash-susarla commented on GitHub (Mar 7, 2020):

@zadjii-msft @DHowett-MSFT Now that the duplicate pane option is in, do you guys think it's possible to get the env vars from that pane ? If so I'd really like to help with it cause it's particularly a pain point for me. Let me know if I can help. Thanks !

@surya-prakash-susarla commented on GitHub (Mar 7, 2020): @zadjii-msft @DHowett-MSFT Now that the duplicate pane option is in, do you guys think it's possible to get the env vars from that pane ? If so I'd really like to help with it cause it's particularly a pain point for me. Let me know if I can help. Thanks !
Author
Owner

@zadjii-msft commented on GitHub (Mar 20, 2020):

I honestly don't think it's possible to get the environment variables of a child process trivially. Plus, if there's a whole tree of processes running in a tab, then which process's environment variables should be the ones duplicated? I'd reckon that this counts as a hard problem

@zadjii-msft commented on GitHub (Mar 20, 2020): I honestly don't think it's possible to get the environment variables of a child process trivially. Plus, if there's a whole tree of processes running in a tab, then which process's environment variables should be the ones duplicated? I'd reckon that this counts as a _hard_ problem
Author
Owner

@surya-prakash-susarla commented on GitHub (Mar 21, 2020):

Yes, it doesn't seem pretty straight forward to bring the env vars from another process and set them here but I'm seriously interested in making this happen cause this would be a unique thing in Terminal different from every other application. If you can give me some pointers I would at least like to explore the possibility. I also think this isn't so walled off since conemu does it ( duplicate root process option). This integrated with duplicate tab would seriously make duplication more useful. Thoughts ? @zadjii-msft

@surya-prakash-susarla commented on GitHub (Mar 21, 2020): Yes, it doesn't seem pretty straight forward to bring the env vars from another process and set them here but I'm seriously interested in making this happen cause this would be a unique thing in Terminal different from every other application. If you can give me some pointers I would at least like to explore the possibility. I also think this isn't so walled off since conemu does it ( duplicate root process option). This integrated with duplicate tab would seriously make duplication more useful. Thoughts ? @zadjii-msft
Author
Owner

@surya-prakash-susarla commented on GitHub (Mar 21, 2020):

I also just realized another alternative, can we allow users to configure env vars when opening profiles. This will allow them to set the vars and just duplicate the profile and everything should still be fine right ?

@surya-prakash-susarla commented on GitHub (Mar 21, 2020): I also just realized another alternative, can we allow users to configure env vars when opening profiles. This will allow them to set the vars and just duplicate the profile and everything should still be fine right ?
Author
Owner

@piotrpalek commented on GitHub (Apr 1, 2020):

Hey I've found this issue because I was searching for the following: I'm not sure how it's for other people, but for me 99% of what I want is to have the split open the same shell in the current path I'm in, would that be something that's doable?

I know there's a PR already in the works for opening a split with the current shell, what about the path?

@piotrpalek commented on GitHub (Apr 1, 2020): Hey I've found this issue because I was searching for the following: I'm not sure how it's for other people, but for me 99% of what I want is to have the split open the same shell in the current path I'm in, would that be something that's doable? I know there's a PR already in the works for opening a split with the current shell, what about the path?
Author
Owner

@zadjii-msft commented on GitHub (Apr 2, 2020):

@piotrpalek You're going to want to take a look at #3158

@zadjii-msft commented on GitHub (Apr 2, 2020): @piotrpalek You're going to want to take a look at #3158
Author
Owner

@a-liashenko commented on GitHub (Aug 13, 2021):

@zadjii-msft @Surya-06
Maybe you can get some clues from ConEmu sources. This application has the feature to duplicate the tab with the same env and CWD. Actually, only the lack of this feature stops me from using Windows Terminal.

@a-liashenko commented on GitHub (Aug 13, 2021): @zadjii-msft @Surya-06 Maybe you can get some clues from ConEmu sources. This application has the feature to duplicate the tab with the same env and CWD. Actually, only the lack of this feature stops me from using Windows Terminal.
Author
Owner

@skyline75489 commented on GitHub (Aug 13, 2021):

@AlexxxRu Funny that you mentioned ConEmu, the CWD part is implemented precisely in the same way as ConEmu. See https://github.com/microsoft/terminal/issues/3158#issuecomment-764003033 and #8330

@skyline75489 commented on GitHub (Aug 13, 2021): @AlexxxRu Funny that you mentioned ConEmu, the CWD part is implemented precisely in the same way as ConEmu. See https://github.com/microsoft/terminal/issues/3158#issuecomment-764003033 and #8330
Author
Owner

@a-liashenko commented on GitHub (Aug 13, 2021):

@skyline75489 Yes, looks so, but env variables are still lost.

@a-liashenko commented on GitHub (Aug 13, 2021): @skyline75489 Yes, looks so, but env variables are still lost.
Author
Owner

@zadjii-msft commented on GitHub (Apr 27, 2022):

Hmm. Still don't know a good way to do this. But looking through https://conemu.github.io/en/ConEmuEnvironment.html#Export_variables

Maybe the clever workaround would be to run the (hypothetical) wt -w 0 new-tab --duplicate or something. By running the new process, it would inherit the current env block, and then the duplicated tab should start with the same variables. (admittedly, we'd still need to transit the env vars through the IPeasant.ExecuteCommandline method, but that's an implementation detail).

I'd still love a more seamless way to do this though that doesn't necessarily involve cooperation from the shell launching a new process, but that might be Hard

@zadjii-msft commented on GitHub (Apr 27, 2022): Hmm. Still don't know a good way to do this. But looking through https://conemu.github.io/en/ConEmuEnvironment.html#Export_variables Maybe the clever workaround would be to run the (hypothetical) `wt -w 0 new-tab --duplicate` or something. By running the new process, it would inherit the current env block, and then the duplicated tab _should_ start with the same variables. (admittedly, we'd still need to transit the env vars through the `IPeasant.ExecuteCommandline` method, but that's an implementation detail). I'd still love a more seamless way to do this though that doesn't necessarily involve cooperation from the shell launching a new process, but that might be **H**ard
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5980