Inherit working directory when terminal is launched via shell or other context #6435

Closed
opened 2026-01-31 00:38:35 +00:00 by claunia · 3 comments
Owner

Originally created by @leidegre on GitHub (Feb 14, 2020).

Description of the new feature/enhancement

From the video below you can see what happens if I launch wt by typing it into the Windows Explorer address bar. This is something I've grown used to doing and it works for cmd.exe. What happens in the case of wt is that it isn't inheriting the working directory. I would very much appreciate if it did so that if it is launched from a specific context is actually has the same working directory.

In this case I expected the terminal to open in C:\Users\leidegre\Source\tessin

You can see here as well, that this isn't limited to the address bar in anyway. It's the same thing if I attempt to launch wt from the old command prompt.

In this case I expected the terminal to open in C:\

Proposed technical implementation details (optional)

Make it so wt respects working directory. So that the new shell has the same working directory as the source that launched wt had (regardless of how it is launched).

Originally created by @leidegre on GitHub (Feb 14, 2020). # Description of the new feature/enhancement From the video below you can see what happens if I launch `wt` by typing it into the Windows Explorer address bar. This is something I've grown used to doing and it works for `cmd.exe`. What happens in the case of `wt` is that it isn't inheriting the working directory. I would very much appreciate if it did so that if it is launched from a specific context is actually has the same working directory. ![](http://g.recordit.co/7I7rC0epE1.gif) In this case I expected the terminal to open in `C:\Users\leidegre\Source\tessin` You can see here as well, that this isn't limited to the address bar in anyway. It's the same thing if I attempt to launch `wt` from the old command prompt. ![](http://g.recordit.co/Vl2CLFIexb.gif) In this case I expected the terminal to open in `C:\` # Proposed technical implementation details (optional) Make it so `wt` respects working directory. So that the new shell has the same working directory as the source that launched `wt` had (regardless of how it is launched).
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-FixNeeds-Attention labels 2026-01-31 00:38:35 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Feb 14, 2020):

The critical issue, and the reason we pin it to the profile's startingDirectory, is here:

So that the new shell has the same working directory as the source that launched wt had (regardless of how it is launched).

When it is launched through the start menu tile, and occasionally (nondeterministically!) through the run dialog, it starts in C:\WINDOWS\System32, which nobody ever wants.

@DHowett-MSFT commented on GitHub (Feb 14, 2020): The critical issue, and the reason we pin it to the profile's `startingDirectory`, is here: > So that the new shell has the same working directory as the source that launched wt had (regardless of how it is launched). When it is launched through the start menu tile, and _occasionally_ (nondeterministically!) through the run dialog, it starts in `C:\WINDOWS\System32`, which nobody ever wants.
Author
Owner

@DHowett-MSFT commented on GitHub (Feb 14, 2020):

More info in #878 (near the bottom), and the abortive PR https://github.com/microsoft/terminal/pull/3547 describes why it didn't end up panning out to have WT figure out where the user wanted to launch.

wt -d . works in all cases, though.

@DHowett-MSFT commented on GitHub (Feb 14, 2020): More info in #878 (near the bottom), and the abortive PR https://github.com/microsoft/terminal/pull/3547 describes why it didn't end up panning out to have WT figure out where the user wanted to launch. `wt -d .` works in all cases, though.
Author
Owner

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

@DHowett-MSFT I'm happy with this.


I get that...

So there's a problem. C:\Windows\System32 is a folder. I'd rather not detect "folders we care about" versus "folders we don't care about," as those two lists can get pretty long.

In my humble opinion, you break an arguably common case (22 up votes) of how people get into the their terminal to avoid a potential pitfall of sometimes ending up in System32?

@leidegre commented on GitHub (Feb 15, 2020): @DHowett-MSFT I'm happy with [this](https://gist.github.com/akunzai/b4b1f394db3ceb399ba1976a30e540fa#file-profiles-json-L9). --- I get that... > So there's a problem. C:\Windows\System32 is a folder. I'd rather not detect "folders we care about" versus "folders we don't care about," as those two lists can get pretty long. In my humble opinion, you break an arguably common case (22 up votes) of how people get into the their terminal to avoid a potential pitfall of sometimes ending up in System32?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6435