[Setting] New tab button should open another of the currently selected tab #663

Open
opened 2026-01-30 21:58:23 +00:00 by claunia · 15 comments
Owner

Originally created by @matthew4850 on GitHub (May 7, 2019).

  • Your Windows build number: 10.0.18890.1000

  • What you're doing and what's happening: When you press the add tab button it always opens cmd.

  • What's wrong / what should be happening instead: It should open another of the currently viewed tab.

Originally created by @matthew4850 on GitHub (May 7, 2019). * Your Windows build number: 10.0.18890.1000 * What you're doing and what's happening: When you press the add tab button it always opens cmd. * What's wrong / what should be happening instead: It should open another of the currently viewed tab.
claunia added the Issue-FeatureHelp WantedProduct-TerminalArea-UserInterface labels 2026-01-30 21:58:23 +00:00
Author
Owner

@zadjii-msft commented on GitHub (May 7, 2019):

It actually opens a new tab of whatever the defaultProfile is, which is the cmd profile by default currently.

We can add a setting that new tab opens a new instance of the active tab instead.

@zadjii-msft commented on GitHub (May 7, 2019): It actually opens a new tab of whatever the `defaultProfile` is, which is the cmd profile by default currently. We can add a setting that new tab opens a new instance of the active tab instead.
Author
Owner

@HBelusca commented on GitHub (May 7, 2019):

I'm by the way wondering what happened to the Windows "Sets" feature that disappeared from the Insider builds some time ago...

@HBelusca commented on GitHub (May 7, 2019): I'm by the way wondering what happened to the Windows "Sets" feature that disappeared from the Insider builds some time ago...
Author
Owner

@zadjii-msft commented on GitHub (May 8, 2019):

this is a trap

I can't say anything about Sets, other than the fact that we wanted to ship a Terminal with tabs before they were able to get us top-level tabs. When Tabbed Sets makes a return, you better believe that we'll be working closely with them to make sure we have the tightest possible integration of our tabs and theirs.

@zadjii-msft commented on GitHub (May 8, 2019): *[this is a trap](https://twitter.com/richturn_ms/status/1119646566782910464?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E1119646566782910464)* I can't say anything about Sets, other than the fact that we wanted to ship a Terminal with tabs before they were able to get us top-level tabs. When Tabbed Sets makes a return, you better believe that we'll be working closely with them to make sure we have the tightest possible integration of our tabs and theirs.
Author
Owner

@zadjii-msft commented on GitHub (Nov 7, 2019):

I discussed this briefly with @DHowett-MSFT today. On the surface, this seems a bit like #1536, which was implemented in #1685. However, this actually has to do with specifically the behavior of the new tab button, not just the keybinding. I'm leaving this open to track changing the behavior of the new tab button.

@zadjii-msft commented on GitHub (Nov 7, 2019): I discussed this briefly with @DHowett-MSFT today. On the surface, this seems a bit like #1536, which was implemented in #1685. However, this actually has to do with specifically the behavior of the new tab _button_, not just the keybinding. I'm leaving this open to track _changing the behavior of the new tab **button**_.
Author
Owner

@momadacoding commented on GitHub (Nov 10, 2019):

As a end user, I understand "dumplicate current tab" means the new tab will be in the same directory as the source, but #1685 does not.
Seems like #1685 is just bind a shortcut to the plus + button's functionality

@momadacoding commented on GitHub (Nov 10, 2019): As a end user, I understand "dumplicate current tab" means the new tab will be in the same directory as the source, but #1685 does not. Seems like #1685 is just bind a shortcut to the plus + button's functionality
Author
Owner

@zadjii-msft commented on GitHub (Jul 8, 2022):

Moving relevant discussion from #11337

Description of the new feature/enhancement

Currently the new tab button opens a terminal the default profile. So for example, with my default set to WSL: Debian, the new tab button will always open with that profile.

Instead I think it'd be nice to have the new tab button open a terminal using the same profile as the currently active tab. This way if I have a non-default profile open, such as PowerShell, the + button would open a new PowerShell tab instead.

Proposed technical implementation details

The default profile could have an additional setting called Currently Active. When a new tab is opened you'd need a way to retrieve the profile of the currently active tab, then open the new tab using that profile.

You know, I might be wrong about that. I had this in my list of "issues to post in the future"

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?

Crazy shower thought:

"newTabButton": {
  "action": { /* duplicate tab*/ },
  "icon": "whatever",
  "showDropdown": false
}

Also related: #6685

I tinkered on this a bit out of curiosity and it turned out to be pretty easy to implement: PathogenDavid@67a370e

diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp
index 752e8e590..96b80f16a 100644
--- a/src/cascadia/TerminalApp/TerminalPage.cpp
+++ b/src/cascadia/TerminalApp/TerminalPage.cpp
@@ -214,5 +214,13 @@ namespace winrt::TerminalApp::implementation
             if (auto page{ weakThis.get() })
             {
-                page->_OpenNewTerminal(NewTerminalArgs());
+                // Duplicate the focused terminal if there is one, otherwise create one from the default profile
+                if (const auto focusedTab{ page->_GetFocusedTabImpl() })
+                {
+                    page->_DuplicateTab(*focusedTab);
+                }
+                else
+                {
+                    page->_OpenNewTerminal(NewTerminalArgs());
+                }
             }
         });

(Unfortunately I'm not very confident I'll have any time soon to formalize it enough to make it a proper contribution, but maybe I'll save someone else a bit of time investigating.)

Edit: Worth noting that this doesn't handle the keyboard shortcuts, just clicking the button. Ctrl+Shift+T comes in in TerminalPage::_HandleNewTab and it already has NewTerminalArgs originating somewhere in the keyboard shortcut event handling schmoo, might look into that more later too.

@zadjii-msft commented on GitHub (Jul 8, 2022): Moving relevant discussion from #11337 > # Description of the new feature/enhancement > Currently the new tab button opens a terminal the default profile. So for example, with my default set to WSL: Debian, the new tab button will always open with that profile. > > Instead I think it'd be nice to have the new tab button open a terminal using the same profile as the currently active tab. This way if I have a non-default profile open, such as PowerShell, the + button would open a new PowerShell tab instead. > > # Proposed technical implementation details > The default profile could have an additional setting called `Currently Active`. When a new tab is opened you'd need a way to retrieve the profile of the currently active tab, then open the new tab using that profile. > You know, I might be wrong about that. I had this in my list of "issues to post in the future" > > > ## 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? > > Crazy shower thought: > > ```js > "newTabButton": { > "action": { /* duplicate tab*/ }, > "icon": "whatever", > "showDropdown": false > } > ``` > > Also related: #6685 > I tinkered on this a bit out of curiosity and it turned out to be pretty easy to implement: [PathogenDavid@67a370e](https://github.com/PathogenDavid/windows-terminal/commit/67a370e5ab5168598fa48491f22c40b5d7ca36fe) > > ```diff > diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp > index 752e8e590..96b80f16a 100644 > --- a/src/cascadia/TerminalApp/TerminalPage.cpp > +++ b/src/cascadia/TerminalApp/TerminalPage.cpp > @@ -214,5 +214,13 @@ namespace winrt::TerminalApp::implementation > if (auto page{ weakThis.get() }) > { > - page->_OpenNewTerminal(NewTerminalArgs()); > + // Duplicate the focused terminal if there is one, otherwise create one from the default profile > + if (const auto focusedTab{ page->_GetFocusedTabImpl() }) > + { > + page->_DuplicateTab(*focusedTab); > + } > + else > + { > + page->_OpenNewTerminal(NewTerminalArgs()); > + } > } > }); > ``` > > (Unfortunately I'm not very confident I'll have any time soon to formalize it enough to make it a proper contribution, but maybe I'll save someone else a bit of time investigating.) > > Edit: Worth noting that this doesn't handle the keyboard shortcuts, just clicking the button. Ctrl+Shift+T comes in in [TerminalPage::_HandleNewTab](https://github.com/microsoft/terminal/blob/a74c37bbcd699ce2cd90bb5d81412663a6236fcc/src/cascadia/TerminalApp/AppActionHandlers.cpp#L292) and it already has `NewTerminalArgs` originating somewhere in the keyboard shortcut event handling schmoo, might look into that more later too.
Author
Owner

@zadjii-msft commented on GitHub (Jul 8, 2022):

pseudo-spec in progress:

scenarios

  • A I want to have the new tab button (NTB) duplicate the active profile, instead of opening the default profile (#445, #11337)
  • B I want the NTB to open a new tab in the CWD of the terminal (#13195)
  • C I want to hide the + part of the NTB (but not the v), (#6608)
  • D I want to hide the v part of the NTB (but not the +), (?)
  • E I want the NTB's dropdown to list profiles AND currently open tabs (#6607)

proposal

"newTabButton": {
  "command": { /* duplicate tab */ },
  "icon": "whatever",
  "showDropdown": false
}

So, to revisit each scenario

  • "command": "duplicateTab"
  • "command": { "action": "newTab", "startingDirectory": "." } should work
  • Maybe "icon": null is a sensible way to hide the + side of the button?
  • "showDropdown":false seems to be a sensible way to hide the dropdown.
  • E may best be supported by an addenda to #1571, and I really don't think we need here. There's a wide gulf between getting the list of open Terminal windows plumbed into the actual XAML layer.

Y'all could be crazy people and have like,

"newTabButton": {
  "command": "toggleCommandPalette",
  "icon": "\uE945",
  "showDropdown": true
}

Cause, why not?


feb 2024 updates:

  • newTabButton could absolutely just be an array of entries. Each either turns into a button or a dropdown button.
  • We should absolutely just use action IDs from #6899
  • The default action ID will just be the Microsoft.Terminal.NewTab ID, and the user can trivially change that by changing the action ID to duplicateTab.
  • it should just be menu: menu: true|false|[NewTabMenuEntry]
"newTabButton": [
  {
    "command": "Microsoft.Terminal.NewTab",
    "icon": "+",
    "menu": true
  },
  {
    "command": "Microsoft.Terminal.CommandPalette",
    "icon": "\uE945",
    "menu": false
  }
]

and that gets us #2934 too.

@zadjii-msft commented on GitHub (Jul 8, 2022): _pseudo-spec in progress:_ ### scenarios * **A** I want to have the new tab button (NTB) duplicate the active profile, instead of opening the default profile (#445, #11337) * **B** I want the NTB to open a new tab in the CWD _of the terminal_ (#13195) * **C** I want to hide the <kbd>+</kbd> part of the NTB (but not the <kbd>v</kbd>), (#6608) * **D** I want to hide the <kbd>v</kbd> part of the NTB (but not the <kbd>+</kbd>), (?) * **E** I want the NTB's dropdown to list profiles AND currently open tabs (#6607) ### proposal ```jsonc "newTabButton": { "command": { /* duplicate tab */ }, "icon": "whatever", "showDropdown": false } ``` So, to revisit each scenario * `"command": "duplicateTab"` * `"command": { "action": "newTab", "startingDirectory": "." }` _should_ work * Maybe `"icon": null` is a sensible way to hide the `+` side of the button? * `"showDropdown":false` seems to be a sensible way to hide the dropdown. * **E** may best be supported by an addenda to #1571, and I _really_ don't think we need here. There's a wide gulf between getting the list of open Terminal windows plumbed into the actual XAML layer. Y'all could be crazy people and have like, ```jsonc "newTabButton": { "command": "toggleCommandPalette", "icon": "\uE945", "showDropdown": true } ``` Cause, why not? ---------- feb 2024 updates: * `newTabButton` could absolutely just be an array of entries. Each either turns into a button or a dropdown button. * We should absolutely just use action IDs from #6899 * The default action ID will just be the `Microsoft.Terminal.NewTab` ID, and the user can trivially change that by changing the action ID to `duplicateTab`. * it should just be `menu`: `menu: true|false|[NewTabMenuEntry]` ```jsonc "newTabButton": [ { "command": "Microsoft.Terminal.NewTab", "icon": "+", "menu": true }, { "command": "Microsoft.Terminal.CommandPalette", "icon": "\uE945", "menu": false } ] ``` and that gets us #2934 too.
Author
Owner

@vertigo220 commented on GitHub (Jul 25, 2022):

Another possibility in addition to this would be the ability to set left-/middle-/right-click options, so e.g. left-clicking the new tab button could open a cmd terminal, right-clicking could open a PS terminal, and middle-clicking a different one, all customizable in settings, of course. And if this were done, what each click does should be shown in the button's tooltip. It could even be further enhanced by opening the new tab either in the CWD or the default one depending on whether a modifier, most likely Ctrl, is used.

@vertigo220 commented on GitHub (Jul 25, 2022): Another possibility _in addition to_ this would be the ability to set left-/middle-/right-click options, so e.g. left-clicking the new tab button could open a cmd terminal, right-clicking could open a PS terminal, and middle-clicking a different one, all customizable in settings, of course. And if this were done, what each click does should be shown in the button's tooltip. It could even be further enhanced by opening the new tab either in the CWD or the default one depending on whether a modifier, most likely Ctrl, is used.
Author
Owner

@marcelwgn commented on GitHub (Jan 8, 2023):

What would be the best way moving forward for this feature?

@marcelwgn commented on GitHub (Jan 8, 2023): What would be the best way moving forward for this feature?
Author
Owner

@zadjii-msft commented on GitHub (May 2, 2023):

@chingucoding Sorry I missed that comment at the start of the year. Next steps here are basically:

  • have me flush out the above comment
  • Discuss with the team some (we'll next have quorum next week probably). I'll probably move for a vote of unanimous consent - it's not a terribly complicated proposal and I think it covers the problem space
  • If there aren't any NAKs then I'll probably turn that into a walkthrough similar to what I did with #1571. I honestly think the settings aren't all that bad so wiring this up shouldn't be that hard...
@zadjii-msft commented on GitHub (May 2, 2023): @chingucoding Sorry I missed that comment at the start of the year. Next steps here are basically: * have me flush out the above comment * Discuss with the team some (we'll next have quorum next week probably). I'll probably move for a vote of unanimous consent - it's not a terribly complicated proposal and I think it covers the problem space * If there aren't any NAKs then I'll probably turn that into a walkthrough similar to what I did with #1571. I honestly think the settings aren't all that bad so wiring this up shouldn't be _that_ hard...
Author
Owner

@zadjii-msft commented on GitHub (May 10, 2023):

Dustin: "As long as I go into the settings and hit save and a newTabButton object doesn't appear, I'm cool with it"

We talked for a while about

  • does that design enable us to do everything we want?
  • does that design preclude us from doing something crazy in the future?

and we were fairly confident that it was good enough. Maybe there should have been some overlap between newTabMenu and newTabButton. Maybe showDropdown should have just been menu, where we stick the newTabMenu json.

The only real sticking point: We can probably get rid of icon, and use the icon of the command itself. If there's no icon on the command, then remove the button.....
But I actually don't love that, because the newTab action doesn't just come with an icon.

Alright so next steps: I need to write a walkthrough

@zadjii-msft commented on GitHub (May 10, 2023): Dustin: "As long as I go into the settings and hit save and a `newTabButton` object doesn't appear, I'm cool with it" We talked for a while about * does that design enable us to do everything we want? * does that design preclude us from doing something crazy in the future? and we were fairly confident that it was good enough. Maybe there should have been some overlap between `newTabMenu` and `newTabButton`. Maybe `showDropdown` should have just been `menu`, where we stick the `newTabMenu` json. The only real sticking point: We can _probably_ get rid of `icon`, and use the `icon` of the `command` itself. If there's no icon on the command, then remove the button..... But I actually don't love that, because the `newTab` action doesn't just come with an icon. Alright so next steps: I need to write a walkthrough
Author
Owner

@zadjii-msft commented on GitHub (Dec 5, 2023):

wow TIL: https://mastodon.social/@JenMsft/111528828382278248

What's a feature you use a lot on your PC that you think other people probably don't know about?

I'll start - middle click on the refresh button in the browser to duplicate the current tab

It's absolutely the least discoverable feature I've ever seen, but I'm 100% here for "middle-click the new tab button duplicates"

@zadjii-msft commented on GitHub (Dec 5, 2023): wow TIL: https://mastodon.social/@JenMsft/111528828382278248 > What's a feature you use a lot on your PC that you think other people probably don't know about? > > I'll start - middle click on the refresh button in the browser to duplicate the current tab It's absolutely the least discoverable feature I've ever seen, but I'm 100% here for "middle-click the new tab button duplicates"
Author
Owner

@PathogenDavid commented on GitHub (Dec 10, 2023):

On one hand I'd probably just prefer duplicate-by-default, but on the other hand I'm a frequent user of the middle-click-refresh gesture so I could certainly get used to doing that in Windows Terminal as well.

@PathogenDavid commented on GitHub (Dec 10, 2023): On one hand I'd probably just prefer duplicate-by-default, but on the other hand I'm a frequent user of the middle-click-refresh gesture so I could certainly get used to doing that in Windows Terminal as well.
Author
Owner

@kyrlon commented on GitHub (Apr 11, 2025):

Has there been any more traction on the development of this?

@kyrlon commented on GitHub (Apr 11, 2025): Has there been any more traction on the development of this?
Author
Owner

@cpriest commented on GitHub (May 28, 2025):

I'm wondering the same as @kyrlon Still wishing duplicateTab actually duplicated the tab (not open a new tab w/ the default profile)

@cpriest commented on GitHub (May 28, 2025): I'm wondering the same as @kyrlon Still wishing duplicateTab actually duplicated the tab (not open a new tab w/ the default profile)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#663