Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut to create new window with current profile? Equivalently, clone current tab into new window #14350

Open
vkoukis opened this issue Nov 6, 2022 · 8 comments
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Milestone

Comments

@vkoukis
Copy link

vkoukis commented Nov 6, 2022

Thank you for your work on the Windows Terminal so far, it's pretty awesome!

Description of the new feature/enhancement

Support a shortcut to create a new window with current profile / clone current tab into a new window. That is, if the current tab uses my non-default "Debian" profile, pressing this shortcut will open a new window with a single tab of the "Debian" profile.

This would be super useful to enable a window-based approach, with tiled windows, and it would go really well with the "Focus" launch mode. I see this was rationale behind the requests to add the "New Window" shortcut, Ctrl-Shift-N in the first place [#1051, #3144]

Workarounds

I am describing a few workarounds below:

  • Ctrl-Shift-N opens a new window, but it always starts with the default profile. I haven't found a way to ask it to use the current profile instead.
  • I can use the mouse to Shift-click on a profile from the dropdown menu. Plus, I can open the dropdown menu easily using Ctrl-Shift-Space, but it's not a single keystroke.
  • I can run wt.exe -p $WT_PROFILE_ID, and I can also alias this for my shell, alias w="wt.exe -p $WT_PROFILE_ID", but this only works in Linux, and requires I'm at the shell prompt.

It would be awesome to have a single, easy to use keystroke [Alt-F2? :) ] to duplicate the current profile into a new window.

Proposed technical implementation details (optional)

There already is a command to start a new window, newWindow.
https://learn.microsoft.com/en-us/windows/terminal/customize-settings/actions#window-management-commands

It already accepts index and profile arguments, but they are absolute. I haven't found a way to refer to the current index/profile.
Maybe we could extend index and/or profile so -1 means "use the index corresponding to the profile of the current tab".
I'd love any feedback on this, and I would be happy to contribute to the implementation.

@vkoukis vkoukis added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Nov 6, 2022
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Nov 6, 2022
@vkoukis vkoukis changed the title Shortcut to create new window with current profile? Equivalently, clone current tab into new window. Shortcut to create new window with current profile? Equivalently, clone current tab into new window Nov 6, 2022
@237dmitry
Copy link

Support a shortcut to create a new window with current profile

If you did not change windowingBehavior you can create shortcuts for every profile, like this

{"command": {"action": "newWindow","profile": "<profile name> or <guid>"},"keys": "ctrl+alt+0"}

but this only works in Linux

Write function and set alias for it:

Screenshot 2022-11-07 122055

@vkoukis
Copy link
Author

vkoukis commented Nov 7, 2022

@237dmitry thank you for your answer. Inline comments follow.

If you did not change windowingBehavior you can create shortcuts for every profile, like this

{"command": {"action": "newWindow","profile": "<profile name> or <guid>"},"keys": "ctrl+alt+0"}

Yes, but this requires pressing a different key combination depending on the current profile, to clone it.
For example:
I have to remember that I'm using the "Debian" profile, so I have to press ctrl-shift-0 o open a new Debian profile.
I have to remember that I'm using the "Ubuntu" profile, so I have to press ctrl-shift-1 to open a new Ubuntu profile.
There is no way to press ctrl-shift-something and have it open a new window for the current profile.

but this only works in Linux

Write function and set alias for it:

I understand this is a Powershell function that runs wt -p $Env:WT_PROFILE_ID. Yes, I can define aliases for all different profiles [a .bat file for Command Prompt, as well...], but it would be much simpler to just support index = -1 or another special value meaning "the current profile" for the newWindow command.

@zadjii-msft
Copy link
Member

This request lives in the same nexus as #10232, #12985. (those are about a tab with different NewTerminalArgs, but the same goes for making windows).

  • duplicateTab doesn't accept NewTerminalArgs.
  • splitPane uses splitMode: duplicate to duplicate the pane, and then accept any additional args as overrides on the current pane's settings.

We basically need a reconciled version of those for newTab and newWindow. Maybe just duplicate: true. Though, there's been debate in the past about "duplicate the current pane as a new tab" vs "duplicate the tree structure of this tab(window) into the new tab(window)". I suspect that the former is easier, and a sensible default for true, and we could add an enum version of duplicate later.

That would effectively deprecate duplicateTab, as that would be a 1-1 alias for newTab(duplicate: true).

@zadjii-msft zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. Issue-Task It's a feature request, but it doesn't really need a major design. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Nov 7, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Nov 7, 2022
@carlos-zamora carlos-zamora added this to the Backlog milestone Nov 7, 2022
@carlos-zamora carlos-zamora removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Nov 7, 2022
@zadjii-msft
Copy link
Member

aside: I wonder if you could get away with multipleActions( actions: [duplicateTab, moveTab(window: -1)]). Essentially, duplicate the current tab (which should make the new one the active one), then move the active tab to a new window. That might work?

@vkoukis
Copy link
Author

vkoukis commented May 31, 2024

aside: I wonder if you could get away with multipleActions( actions: [duplicateTab, moveTab(window: -1)]). Essentially, duplicate the current tab (which should make the new one the active one), then move the active tab to a new window. That might work?

@zadjii-msft Definitely! What you describe is exactly what I need, it combines two actions to clone the current tab into a new window. However, I haven't been successful yet, plus the Terminal just crashes sometimes, which seems like a bug in its own right.

Here are more details:

The following works to move the current tab into a new window [I'm using multipleActions because I will need it later on]:

{
    "command":
    {
        "action": "multipleActions",
        "actions":
        [
            {
                "action": "moveTab",
                "window": "new"
            }
        ]
    },
    "keys": "ctrl+shift+f12"
},

But this causes the terminal to crash:

{
    "command":
    {
        "action": "multipleActions",
        "actions":
        [
            {
                "action": "duplicateTab"
            },
            {
                "action": "moveTab",
                "window": "new"
            }
        ]
    },
    "keys": "ctrl+shift+f12"
},

I'm running Windows Terminal Preview / Version: 1.21.1272.0.

Independently of this, I'm testing with the ctrl+shift+f12 key combination, because I can't get alt+f2 to work for some reason. It's not my biggest concern now, but maybe you have something in mind.

Any next steps I can try / anything that comes to mind?
Thanks, for suggesting this workaround, it seems really promising!

@vkoukis
Copy link
Author

vkoukis commented May 31, 2024

@zadjii-msft Hehe, using multipleActions with just the duplicateTab action works, but it only duplicates the tab. Similarly, just the moveTab action works. Combining them both in multipleActions causes the terminal to crash.

This looks like a bug, shall I open it as a separate issue?
This is a similar bug where manipulating tabs as part of multipleActions was causing issues:
#11107
It seems related to this fix:
#11144

Maybe I'm hitting a similar issue now.

@zadjii-msft
Copy link
Member

This looks like a bug, shall I open it as a separate issue

Definitely! Crashes are absolutely no good, can't have those!

@vkoukis
Copy link
Author

vkoukis commented May 31, 2024

This looks like a bug, shall I open it as a separate issue

Definitely! Crashes are absolutely no good, can't have those!

@zadjii-msft Done! It seems your suggestion is a perfect solution to this issue, so I'm really looking forward to seeing it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

5 participants
@vkoukis @carlos-zamora @zadjii-msft @237dmitry and others