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

Open
opened 2026-01-31 06:25:58 +00:00 by claunia · 8 comments
Owner

Originally created by @vkoukis on GitHub (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.

Originally created by @vkoukis on GitHub (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.
claunia added the Area-SettingsIssue-TaskProduct-Terminal labels 2026-01-31 06:25:59 +00:00
Author
Owner

@237dmitry commented on GitHub (Nov 7, 2022):

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

@237dmitry commented on GitHub (Nov 7, 2022): > 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](https://user-images.githubusercontent.com/78153320/200273625-98fdc7fb-d24b-4814-a543-13a9d23f9949.png)
Author
Owner

@vkoukis commented on GitHub (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.

@vkoukis commented on GitHub (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.
Author
Owner

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

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 commented on GitHub (Nov 7, 2022): 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)`.
Author
Owner

@zadjii-msft commented on GitHub (May 29, 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 commented on GitHub (May 29, 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?
Author
Owner

@vkoukis commented on GitHub (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 commented on GitHub (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]: ```json { "command": { "action": "multipleActions", "actions": [ { "action": "moveTab", "window": "new" } ] }, "keys": "ctrl+shift+f12" }, ``` But this causes the terminal to crash: ```json { "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!
Author
Owner

@vkoukis commented on GitHub (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:
https://github.com/microsoft/terminal/issues/11107
It seems related to this fix:
https://github.com/microsoft/terminal/pull/11144

Maybe I'm hitting a similar issue now.

@vkoukis commented on GitHub (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: https://github.com/microsoft/terminal/issues/11107 It seems related to this fix: https://github.com/microsoft/terminal/pull/11144 Maybe I'm hitting a similar issue now.
Author
Owner

@zadjii-msft commented on GitHub (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 commented on GitHub (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!
Author
Owner

@vkoukis commented on GitHub (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.

@vkoukis commented on GitHub (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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18839