newTab on current path #3236

Closed
opened 2026-01-30 23:16:30 +00:00 by claunia · 3 comments
Owner

Originally created by @trajano on GitHub (Aug 7, 2019).

Description of the new feature/enhancement

When opening a new tab AND OPTIONALLY if the current program in the active shell is not the shell program, use the current path of the active shell as the default path for the newTab action.

Proposed technical implementation details (optional)

There should be an option for this. useCurrentPath in globals which takes in a string of "never", "always", "whenNotShell"

Originally created by @trajano on GitHub (Aug 7, 2019). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 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 When opening a new tab AND OPTIONALLY if the current program in the active shell is not the shell program, use the current path of the active shell as the default path for the `newTab` action. <!-- 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) <!-- A clear and concise description of what you want to happen. --> There should be an option for this. `useCurrentPath` in `globals` which takes in a string of "never", "always", "whenNotShell"
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-Fix labels 2026-01-30 23:16:30 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Aug 8, 2019):

This is one of those things that is impossible in the general case but technically possible. There's a lot of intricacies here, like:

cmd
powershell
cd d:\users

well, powershell isn't the first process we launched. we'd ignore the path d:\users

(in powershell)
cd d:\users

we'd ignore d:\users because powershell doesn't actually set the current working directory (!!)

If your "shell" is ssh dustin@example.com (where we strictly define shell to be "the first process Terminal spawns on your behalf"), its working directory is always going to be C:\windows\system32 regardless of what the remote working directory is.

I'd rather not provide the feature than provide the feature with so many caveats that they'd fill a documentation page. ☹️ sorry.

@DHowett-MSFT commented on GitHub (Aug 8, 2019): This is one of those things that is impossible in the general case but _technically possible_. There's a lot of intricacies here, like: ``` cmd powershell cd d:\users ``` well, powershell isn't the first process we launched. we'd ignore the path `d:\users` ``` (in powershell) cd d:\users ``` we'd ignore `d:\users` because powershell _doesn't actually set the current working directory_ (!!) If your "shell" is `ssh dustin@example.com` (where we strictly define shell to be "the first process Terminal spawns on your behalf"), its working directory is always going to be `C:\windows\system32` regardless of what the remote working directory is. I'd rather not provide the feature than provide the feature with so many caveats that they'd fill a documentation page. ☹️ sorry.
Author
Owner

@DHowett-MSFT commented on GitHub (Aug 8, 2019):

Thanks, nonetheless, for the suggestion. We'll keep thinking about this.

@DHowett-MSFT commented on GitHub (Aug 8, 2019): Thanks, nonetheless, for the suggestion. We'll keep thinking about this.
Author
Owner

@trajano commented on GitHub (Aug 8, 2019):

Hmm that's kind of odd. I would think it's just a matter of reading the process' current directory https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcurrentdirectory and calling https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw with the directory (then again I haven't traversed through the code base yet).

The part I don't know the API for would likely be trying to determine the process itself which I think should be possible because ProcExp shows the following tree

image

But then even the example above if I used git bash it will be in the wrong folder if you're looking at the first process under conhost.exe

@trajano commented on GitHub (Aug 8, 2019): Hmm that's kind of odd. I would think it's just a matter of reading the process' current directory https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcurrentdirectory and calling https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw with the directory (then again I haven't traversed through the code base yet). The part I don't know the API for would likely be trying to determine the process itself which I think should be possible because ProcExp shows the following tree ![image](https://user-images.githubusercontent.com/110627/62714196-16e3b700-b9cc-11e9-9f5f-7d7a79ca88ba.png) But then even the example above if I used git bash it will be in the wrong folder if you're looking at the first process under `conhost.exe`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#3236