Open different shell in same directory #13982

Open
opened 2026-01-31 03:57:40 +00:00 by claunia · 14 comments
Owner

Originally created by @ghost on GitHub (May 27, 2021).

Description of the new feature/enhancement

Sometimes, it so happens that I am in (lets say) powershell, and i am working on something, and i change directory to some location, and i find myself in need of a different shell for some reason. Just as an example, maybe i have to run a bash script present in that directory using Git Bash / Msys.

Asked this on reddit and @zadjii-msft asked to open an issue here

Proposed technical implementation details (optional)

No idea

Originally created by @ghost on GitHub (May 27, 2021). # Description of the new feature/enhancement Sometimes, it so happens that I am in (lets say) powershell, and i am working on something, and i change directory to some location, and i find myself in need of a different shell for some reason. Just as an example, maybe i have to run a bash script present in that directory using Git Bash / Msys. Asked this on [reddit](https://old.reddit.com/r/programming/comments/nkrwnf/windows_terminal_preview_19_release/gzi0qyj/) and @zadjii-msft asked to open an issue here # Proposed technical implementation details (optional) No idea
claunia added the Issue-FeatureArea-SettingsProduct-Terminal labels 2026-01-31 03:57:40 +00:00
Author
Owner

@skyline75489 commented on GitHub (May 27, 2021):

I have read the reddit post. This is possible and was actually implemented at the early days of #8166 when we were still trying to make OSC 7 work. Later reusing the CWD was limited to only duplicating tabs/panes, to prevent the feature from being too aggressive. Maybe we can add an option for folks who do love to reuse CWD for every tab created.

@skyline75489 commented on GitHub (May 27, 2021): I have read the reddit post. This is possible and was actually implemented at the early days of #8166 when we were still trying to make OSC 7 work. Later reusing the CWD was limited to only duplicating tabs/panes, to prevent the feature from being too aggressive. Maybe we can add an option for folks who do love to reuse CWD for every tab created.
Author
Owner

@mveril commented on GitHub (May 27, 2021):

I have read the reddit post. This is possible and was actually implemented at the early days of #8166 when we were still trying to make OSC 7 work. Later reusing the CWD was limited to only duplicating tabs/panes, to prevent the feature from being too aggressive. Maybe we can add an option for folks who do love to reuse CWD for every tab created.

I think it could be also a command in the command palette

@mveril commented on GitHub (May 27, 2021): > I have read the reddit post. This is possible and was actually implemented at the early days of #8166 when we were still trying to make OSC 7 work. Later reusing the CWD was limited to only duplicating tabs/panes, to prevent the feature from being too aggressive. Maybe we can add an option for folks who do love to reuse CWD for every tab created. I think it could be also a command in the command palette
Author
Owner

@Vendetta8247 commented on GitHub (May 27, 2021):

This proposal is exactly the first thing I noticed "missing" when working on the new Terminal (just installed today and wasn't sure if I just didn't dive too deep). My personal use case: I'm working on Windows and writing a tool using bash and perl scripts. Still I prefer managing git through PowerShell (and access to files as well) and use cmd for local management inside Windows with the long familiar commands. Usually I just open Terminal as WSL but when I do commits or other stuff it's just easier to Shift+Right Click and open Powershell from the menu rather than opening a new tab and navigating into the directory. And IMO it defeats the purpose of having multiple different terminals inside one window. No matter how convenient it sounds (and in general it is very convenient) but in this case it's just not the most optimal way.

Also - the best possible scenario would be having these option:

  • set default dir of opening new window to the same as the currently opened terminal's dir
  • add an action to have an opportunity to open new tab in the same dir or in a default dir
@Vendetta8247 commented on GitHub (May 27, 2021): This proposal is exactly the first thing I noticed "missing" when working on the new Terminal (just installed today and wasn't sure if I just didn't dive too deep). My personal use case: I'm working on Windows and writing a tool using bash and perl scripts. Still I prefer managing git through PowerShell (and access to files as well) and use cmd for local management inside Windows with the long familiar commands. Usually I just open Terminal as WSL but when I do commits or other stuff it's just easier to Shift+Right Click and open Powershell from the menu rather than opening a new tab and navigating into the directory. And IMO it defeats the purpose of having multiple different terminals inside one window. No matter how convenient it sounds (and in general it is very convenient) but in this case it's just not the most optimal way. Also - the best possible scenario would be having these option: - set default dir of opening new window to the same as the currently opened terminal's dir - add an action to have an opportunity to open new tab in the same dir or in a default dir
Author
Owner

@zadjii-msft commented on GitHub (May 27, 2021):

Hmmmmmmmmmm.

Now that I'm thinking about this, and comparing more with the rest of the repo, this might be an argument in favor of option 1 in #9957. We want to duplicate the path, but change the profile.

Oh no, wait it might be more complicated than that. It's "mode: duplicatePath", not duplicateProfile. Hmm.

@zadjii-msft commented on GitHub (May 27, 2021): Hmmmmmmmmmm. Now that I'm thinking about this, and comparing more with the rest of the repo, this might be an argument in favor of option 1 in #9957. We want to duplicate the path, but change the profile. Oh no, wait it might be more complicated than that. It's "mode: duplicatePath", not `duplicateProfile`. Hmm.
Author
Owner

@zadjii-msft commented on GitHub (May 27, 2021):

  • set default dir of opening new window to the same as the currently opened terminal's dir

oh boy that seems awfully specific - the new window duplicates the existing window's CWD? I'm cool doing this with a new tab, but the window seems like it might be confusing.

I even typed up an issue like this in the past, but I don't think I ever posted it

Add a setting to default the new tab button to "duplicate tab" instead of "open default profile"

Maybe that applies to the splitPane actions as well?

Is this just asking for "toolbar customization" though? Should this be an extension? How would we let an extension do that?

Would they get at the tab row, hide the new tab button, then add their own split button, with the same new tab menu, but with duplicateTab bound instead?

I think on discussion, we thought that this made a good extension candidate, but those are also 12+mos away, so maybe we should revisit

  • add an action to have an opportunity to open new tab in the same dir or in a default dir

Like, as a prompt? Like a different version of #3586? Otherwise you can of course just use duplicateTab or newTab today

  • (this is very theoretical) to have an opportunity to open a new tab for existing terminal window from Right clicking inside the folder - same as you can open Terminal now, but to add an option "Open as a new tab in Terminal)

That's over in #7071

@zadjii-msft commented on GitHub (May 27, 2021): > * set default dir of opening new window to the same as the currently opened terminal's dir oh boy that seems awfully specific - the new _window_ duplicates the existing _window_'s CWD? I'm cool doing this with a new _tab_, but the window seems like it might be confusing. I even typed up an issue like this in the past, but I don't think I ever posted it > ## Add a setting to default the new tab button to "duplicate tab" instead of "open default profile" > Maybe that applies to the `splitPane` actions as well? > > Is this just asking for "toolbar customization" though? Should this be an extension? How would we let an extension do that? > > Would they get at the tab row, hide the new tab button, then add their own split button, with the same new tab menu, but with `duplicateTab` bound instead? I think on discussion, we thought that this made a good extension candidate, but those are also 12+mos away, so maybe we should revisit > * add an action to have an opportunity to open new tab in the same dir or in a default dir Like, as a prompt? Like a different version of #3586? Otherwise you can of course just use `duplicateTab` _or_ `newTab` today > * (this is very theoretical) to have an opportunity to open a new tab for existing terminal window from Right clicking inside the folder - same as you can open Terminal now, but to add an option "Open as a new tab in Terminal) That's over in #7071
Author
Owner

@Vendetta8247 commented on GitHub (May 27, 2021):

oh boy that seems awfully specific - the new window duplicates the existing window's CWD? I'm cool doing this with a new tab, but the window seems like it might be confusing.

I'm so sorry for the confusion, I actually meant a new Tab. Was just in a rush to get my vision out 😒
I'm not sure how other people manage their terminals as I'm still a rookie in this, but I usually prefer having a:

  1. "group" of terminals for one specific task/folder. It would either be one project with a need of different terminals or subfolders open in tabs.
  2. Having a "git" terminal window with multiple repositories in tabs.

In first case I would definitely prefer to have tabs open in the same folder and then navigating to subfolder. Or simply opening a WSL/cmd/gitbash in the same folder. As you can see - it's pretty apparent why having a current folder option would be benefitial

In second case I would just open a new window - as it's working now.

That's over in #7071

This is kind of off-topic for this issue so I'll stop about that but yes, indeed. Excuse me for that as I haven't noticed the setting as I'm really really new to this Terminal

@Vendetta8247 commented on GitHub (May 27, 2021): > oh boy that seems awfully specific - the new _window_ duplicates the existing _window_'s CWD? I'm cool doing this with a new _tab_, but the window seems like it might be confusing. I'm so sorry for the confusion, I actually meant a new Tab. Was just in a rush to get my vision out 😒 I'm not sure how other people manage their terminals as I'm still a rookie in this, but I usually prefer having a: 1. "group" of terminals for one specific task/folder. It would either be one project with a need of different terminals or subfolders open in tabs. 2. Having a "git" terminal window with multiple repositories in tabs. In first case I would definitely prefer to have tabs open in the same folder and then navigating to subfolder. Or simply opening a WSL/cmd/gitbash in the same folder. As you can see - it's pretty apparent why having a current folder option would be benefitial In second case I would just open a new window - as it's working now. > That's over in #7071 This is kind of off-topic for this issue so I'll stop about that but yes, indeed. Excuse me for that as I haven't noticed the setting as I'm really really new to this Terminal
Author
Owner

@orcmid commented on GitHub (Jun 15, 2021):

It strikes me that terminal is not at the layer that knows another shell instance's Current Working Directory. I assume the shell tied to the terminal (tab) via stdin, stdout, and stderr that has such information, not WT. And the shell (and any other command-line app) might not be designed to detect wiring to WT and Terminal Tabs at all.

A shell's ability to Start an asynchronous console application might be helpful, although having that wired to a new tab sort of reduces to the previously-unsolved problem.

@orcmid commented on GitHub (Jun 15, 2021): It strikes me that terminal is not at the layer that knows another shell instance's Current Working Directory. I assume the shell tied to the terminal (tab) via stdin, stdout, and stderr that has such information, not WT. And the shell (and any other command-line app) might not be designed to detect wiring to WT and Terminal Tabs at all. A shell's ability to Start an asynchronous console application might be helpful, although having that wired to a new tab sort of reduces to the previously-unsolved problem.
Author
Owner

@TBBle commented on GitHub (Jun 15, 2021):

This is actually the original request in #3158, but since https://github.com/microsoft/terminal/issues/3158#issuecomment-770206512 where I called out the next step, that ticket has been filled with people working out how to emit OSC 9;9 in their particular shell environment, so it might make sense to mark that ticket as "Done, but for duplicate/split-duplicate tabs" and work against this ticket for "New tab/pane" support.

@orcmid Windows Terminal uses the OSC 9;9 command to know the current working directory, so that part's already done, except you have to teach your shells to emit it.

So this use-case is mostly about how we apply that knowledge to "New Tab", or "Split Tab (Not duplicate)", since just changing the default behaviour with no recourse would probably be surprising, while "Duplicate Tab" and "Duplicate Pane" carrying the CWD is pretty hard to disagree with.

@TBBle commented on GitHub (Jun 15, 2021): This is actually the original request in #3158, but since https://github.com/microsoft/terminal/issues/3158#issuecomment-770206512 where I called out the next step, that ticket has been filled with people working out how to emit `OSC 9;9` in their particular shell environment, so it might make sense to mark that ticket as "Done, but for duplicate/split-duplicate tabs" and work against this ticket for "New tab/pane" support. @orcmid Windows Terminal uses the `OSC 9;9` command to know the current working directory, so that part's already done, except you have to teach your shells to emit it. So this use-case is mostly about how we _apply_ that knowledge to "New Tab", or "Split Tab (Not duplicate)", since just changing the default behaviour with no recourse would probably be surprising, while "Duplicate Tab" and "Duplicate Pane" carrying the CWD is pretty hard to disagree with.
Author
Owner

@zadjii-msft commented on GitHub (Jul 6, 2021):

work against this ticket for "New tab/pane" support.

I'm sold. I'll stick it on the backlog. We'll have to come up with some sort of sensible setting for this. Maybe something like an enum - useTheStartingDirectory|useTheCWD|useTheTerminalsCWD, idk.

@zadjii-msft commented on GitHub (Jul 6, 2021): > work against this ticket for "New tab/pane" support. I'm sold. I'll stick it on the backlog. We'll have to come up with some sort of sensible setting for this. Maybe something like an enum - `useTheStartingDirectory|useTheCWD|useTheTerminalsCWD`, idk.
Author
Owner

@sheikalthaf commented on GitHub (Sep 3, 2021):

@zadjii-msft Any update on this. I regularly duplicate the tab with same directory? But it is very hard to type every time the directory path. I really miss this feature from linux terminal

@sheikalthaf commented on GitHub (Sep 3, 2021): @zadjii-msft Any update on this. I regularly duplicate the tab with same directory? But it is very hard to type every time the directory path. I really miss this feature from linux terminal
Author
Owner

@TBBle commented on GitHub (Sep 3, 2021):

@sheikalthaf: If you're duplicating the tab, it should already be keeping the current working directory as of Windows Terminal 1.6, if you have OSC 9;9 set up.

If you don't have OSC 9;9 set up, then the docs are a bit sparse (https://github.com/MicrosoftDocs/terminal/issues/285) but there's a bunch of examples in #3158 comments for now.

@TBBle commented on GitHub (Sep 3, 2021): @sheikalthaf: If you're _duplicating_ the tab, it should already be keeping the current working directory as of Windows Terminal 1.6, if you have `OSC 9;9` set up. If you don't have `OSC 9;9` set up, then the docs are a bit sparse (https://github.com/MicrosoftDocs/terminal/issues/285) but there's a bunch of examples in #3158 comments for now.
Author
Owner

@s-celles commented on GitHub (Oct 21, 2021):

I'm also looking for a way to duplicate a tab and keep existing current working directory

 cd my_path

for each duplicated tab is just an extra step which could be avoid.

This behavior should be "out of the box" when installing new version of Terminal

@s-celles commented on GitHub (Oct 21, 2021): I'm also looking for a way to duplicate a tab and keep existing current working directory cd my_path for each duplicated tab is just an extra step which could be avoid. This behavior should be "out of the box" when installing new version of Terminal
Author
Owner

@TBBle commented on GitHub (Oct 21, 2021):

@scls19fr You're commenting on a ticket about new tabs or splits, not duplicating tabs or splits. Duplicating tabs is #3158, and that's already as done as possible in Windows Terminal; to be truly out-of-the-box, you need your shell to be updated to send the OSC 9;9 information so that Windows Terminal knows your "current working directory", e.g., for PowerShell there's a ticket open at https://github.com/PowerShell/PowerShell/issues/15469 requesting this.

In the meantime, every shell I've come across has had a mechanism to let the user hook something to send that information, and there's a ton of recipes in the history #3158, and eventually, someone will document it nicely in https://github.com/MicrosoftDocs/terminal/issues/285.

@TBBle commented on GitHub (Oct 21, 2021): @scls19fr You're commenting on a ticket about _new_ tabs or splits, not duplicating tabs or splits. Duplicating tabs is #3158, and that's already as done as possible in Windows Terminal; to be truly out-of-the-box, you need your shell to be updated to send the `OSC 9;9` information so that Windows Terminal knows your "current working directory", e.g., for PowerShell there's a ticket open at https://github.com/PowerShell/PowerShell/issues/15469 requesting this. In the meantime, every shell I've come across has had a mechanism to let the user hook something to send that information, and there's a ton of recipes in the history #3158, and _eventually_, someone will document it nicely in https://github.com/MicrosoftDocs/terminal/issues/285.
Author
Owner

@0xdw commented on GitHub (Feb 18, 2022):

I would suggest something like this?

image

@0xdw commented on GitHub (Feb 18, 2022): I would suggest something like this? ![image](https://user-images.githubusercontent.com/12568779/154602876-2c57324d-0ea0-4546-adb0-5ae3c62075c6.png)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13982