New tab doesn't inherit working directory for -d #22958

Closed
opened 2026-01-31 08:28:26 +00:00 by claunia · 8 comments
Owner

Originally created by @QuAzI on GitHub (Feb 20, 2025).

Windows Terminal version

1.22.10352.0

Windows build number

10.0.19045.0

Other Software

No response

Steps to reproduce

Press Win+R
Execute wt -d c:\Projects to specify the folder that should be used as the starting directory for the console (according to documentation)
Open a new tab

Expected Behavior

For cases when wt -d used target directory should be inherited properly for new tabs and should be equal as the starting directory specified on console run

Actual Behavior

Currently, the path is C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.22.10352.0_x64__8wekyb3d8bbwe> instead of what you chose as the starting directory

Originally created by @QuAzI on GitHub (Feb 20, 2025). ### Windows Terminal version 1.22.10352.0 ### Windows build number 10.0.19045.0 ### Other Software _No response_ ### Steps to reproduce Press Win+R Execute `wt -d c:\Projects` to specify the folder that should be used as the starting directory for the console (according to [documentation](https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows#target-a-directory)) Open a new tab ### Expected Behavior For cases when `wt -d` used target directory should be inherited properly for new tabs and should be equal as the starting directory specified on console run ### Actual Behavior Currently, the path is `C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.22.10352.0_x64__8wekyb3d8bbwe>` instead of what you chose as the starting directory
Author
Owner

@zadjii-msft commented on GitHub (Feb 26, 2025):

Lemme at least cross link some thoughts here:

If I'm reading you right, you basically want to be able to have -d . apply to additional tabs created in that terminal window, not just the tab that wt -d . opens. I suspect that just using "Duplicate tab" rather than "Open new tab" will probably get you want you want here.

@zadjii-msft commented on GitHub (Feb 26, 2025): Lemme at least cross link some thoughts here: * #14761 * #14817 (similar root cause, though that thread is very leveation specific) * #4637 IIRC is the thread where I was collecting all of these thoughts up If I'm reading you right, you basically want to be able to have `-d .` apply to additional tabs created in that terminal window, not just the tab that `wt -d .` opens. I suspect that just using "Duplicate tab" rather than "Open new tab" will probably get you want you want here.
Author
Owner

@QuAzI commented on GitHub (Feb 27, 2025):

-d . means that I will use the current directory, not the starting directory. So, it's different.
At the same time, Duplicate tab starts with the starting directory, while I expected that it will inherit the current path too) And it absolutely doesn't work for different profiles, WSL for example

@QuAzI commented on GitHub (Feb 27, 2025): `-d .` means that I will use the current directory, not the starting directory. So, it's different. At the same time, `Duplicate tab` starts with the starting directory, while I expected that it will inherit the current path too) And it absolutely doesn't work for different profiles, WSL for example
Author
Owner

@quyenvsp commented on GitHub (Mar 18, 2025):

same here, I remember it work before but not latest Terminal Preview version. Duplicate tab work but can not switch profile like from Git bash to CMD. new CMD tab will open system32 instead of Parent process directory

@quyenvsp commented on GitHub (Mar 18, 2025): same here, I remember it work before but not latest Terminal Preview version. `Duplicate tab` work but can not switch profile like from Git bash to CMD. new CMD tab will open `system32` instead of `Parent process directory`
Author
Owner

@DHowett commented on GitHub (Mar 26, 2025):

This may have regressed in our windowing and remoting rewrite in #18215. Thanks!

@DHowett commented on GitHub (Mar 26, 2025): This may have regressed in our windowing and remoting rewrite in #18215. Thanks!
Author
Owner

@DHowett commented on GitHub (Mar 26, 2025):

Actually, given that the original report is on 1.22 and @quyenvsp is talking about Preview... there may be two issues here.

@DHowett commented on GitHub (Mar 26, 2025): Actually, given that the original report is on 1.22 and @quyenvsp is talking about Preview... there may be two issues here.
Author
Owner

@zadjii-msft commented on GitHub (Mar 27, 2025):

okay team notes:

  • "duplicate tab" needs to copy the NewTerminalArgs from the previous tab, not sure if we did all those. Pretty sure there's a thread for that. But IIRC we already duplicated the CWD.
  • -d . is Special though, cause it has to evaluate based on the CWD that the wt command was run in.
  • So duplicating a tab with -d . needs to evaluate the startingDirectory not as . but as... one of?
    • the CWD of the tab being duplicated (else the CWD that tab was launched in)
    • just the CWD that tab was launched in (ignore the CWD of that tab now)
@zadjii-msft commented on GitHub (Mar 27, 2025): okay team notes: * "duplicate tab" needs to copy the NewTerminalArgs from the previous tab, not sure if we did _all_ those. Pretty sure there's a thread for that. But IIRC we already duplicated the CWD. * `-d .` is Special though, cause it has to evaluate based on the CWD that the `wt` command was run in. * So duplicating a tab with `-d .` needs to evaluate the `startingDirectory` not as `.` but as... one of? * the CWD of the tab being duplicated (else the CWD that tab was launched in) * just the CWD that tab was launched in (ignore the CWD of that tab now)
Author
Owner

@QuAzI commented on GitHub (Mar 27, 2025):

For me Duplicate sounds like "same shell in the same path", so CWD of the tab being duplicated. But NEW tab ("+") should be based on CWD that main tab/wt was launched

@QuAzI commented on GitHub (Mar 27, 2025): For me Duplicate sounds like "same shell in the same path", so CWD of the tab being duplicated. But NEW tab ("+") should be based on CWD that main tab/wt was launched
Author
Owner

@lhecker commented on GitHub (Apr 16, 2025):

Oh, I forgot to close this issue when I fixed the bug in #18801. It'll go out in the next bug fix release. Thanks everyone!

@lhecker commented on GitHub (Apr 16, 2025): Oh, I forgot to close this issue when I fixed the bug in #18801. It'll go out in the next bug fix release. Thanks everyone!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22958