terminal icon indicating copy to clipboard operation
terminal copied to clipboard

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

Open matthew4850 opened this issue 6 years ago • 15 comments

  • 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.

matthew4850 avatar May 06 '19 23:05 matthew4850

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 avatar May 07 '19 16:05 zadjii-msft

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

HBelusca avatar May 07 '19 22:05 HBelusca

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 avatar May 08 '19 13:05 zadjii-msft

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 avatar Nov 07 '19 23:11 zadjii-msft

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 avatar Nov 10 '19 18:11 momadacoding

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 avatar Jul 08 '22 10:07 zadjii-msft

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 avatar Jul 08 '22 11:07 zadjii-msft

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 avatar Jul 25 '22 00:07 vertigo220

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

marcelwgn avatar Jan 08 '23 14:01 marcelwgn

@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 avatar May 02 '23 19:05 zadjii-msft

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 avatar May 10 '23 11:05 zadjii-msft

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 avatar Dec 05 '23 21:12 zadjii-msft

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 avatar Dec 10 '23 15:12 PathogenDavid

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

kyrlon avatar Apr 11 '25 02:04 kyrlon

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

cpriest avatar May 28 '25 14:05 cpriest