Implement a keybinding to restart/reload a tab #5215

Closed
opened 2026-01-31 00:07:43 +00:00 by claunia · 19 comments
Owner

Originally created by @matt-beamish on GitHub (Nov 27, 2019).

Description of the new feature/enhancement

ConEmu has a default binding of Win+tilde to reload/restart the current tab. This would be a useful feature to add to Windows Terminal, specifically to resolve issues whereby a fresh start of a tab is useful (eg: crashes, troubleshooting).

Originally created by @matt-beamish on GitHub (Nov 27, 2019). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement ConEmu has a default binding of Win+tilde to reload/restart the current tab. This would be a useful feature to add to Windows Terminal, specifically to resolve issues whereby a fresh start of a tab is useful (eg: crashes, troubleshooting). <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). -->
claunia added the Issue-TaskIn-PRProduct-TerminalArea-TerminalControl labels 2026-01-31 00:07:43 +00:00
Author
Owner

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

Yea, I guess I could see that being useful. Thanks for the suggestion!

@zadjii-msft commented on GitHub (Nov 27, 2019): Yea, I guess I could see that being useful. Thanks for the suggestion!
Author
Owner

@dominik-ba commented on GitHub (Jun 20, 2020):

Agreed! Just want to add a concrete example:
You make a change on ~/.bashrc (or similar things) and don't want to do a source ... but a simple tab realod.

@dominik-ba commented on GitHub (Jun 20, 2020): Agreed! Just want to add a concrete example: You make a change on ~/.bashrc (or similar things) and don't want to do a source ... but a simple tab realod.
Author
Owner

@DHowett commented on GitHub (Jun 20, 2020):

I mean, you could just exec bash -li. Terminal would destroy the process tree and relaunch it; is that really what you want instead of just sourcing your .bashrc again?

@DHowett commented on GitHub (Jun 20, 2020): I mean, you could just `exec bash -li`. Terminal would destroy the process tree and relaunch it; is that really what you want instead of just sourcing your `.bashrc` again?
Author
Owner

@dominik-ba commented on GitHub (Jun 20, 2020):

I think there is no definitive answer to your question but imho a relaunch as you described it would often be good enough and with a keybinding the comfort wins :)

@dominik-ba commented on GitHub (Jun 20, 2020): I think there is no definitive answer to your question but imho a relaunch as you described it would often be good enough and with a keybinding the comfort wins :)
Author
Owner

@zadjii-msft commented on GitHub (Jun 22, 2020):

Hey I'm gonna cross-link a pair of issues:

  • This would be a good idea to include in the context menu, #1912
  • This could be built directly into the connection somehow? With #4379 perhaps?
@zadjii-msft commented on GitHub (Jun 22, 2020): Hey I'm gonna cross-link a pair of issues: * This would be a good idea to include in the context menu, #1912 * This could be built directly into the connection somehow? With #4379 perhaps?
Author
Owner

@dseven commented on GitHub (Dec 28, 2020):

FWIW; I use Terminal tabs to ssh to other hosts a lot. When those ssh connections get dropped - e.g. I reboot the remote host, or there's some sort of network interruption - I keep wishing I could right-click on the tab and select a "restart" option of some sort, rather than having to close the dead tab, open a new one, then drag it to the position the old one was occupying.

@dseven commented on GitHub (Dec 28, 2020): FWIW; I use Terminal tabs to ssh to other hosts a lot. When those ssh connections get dropped - e.g. I reboot the remote host, or there's some sort of network interruption - I keep wishing I could right-click on the tab and select a "restart" option of some sort, rather than having to close the dead tab, open a new one, then drag it to the position the old one was occupying.
Author
Owner

@bbeckford commented on GitHub (Feb 1, 2021):

+1 for this feature - being able to ctrl+r an SSH session would be super useful!

@bbeckford commented on GitHub (Feb 1, 2021): +1 for this feature - being able to <kbd>ctrl</kbd>+<kbd>r</kbd> an SSH session would be super useful!
Author
Owner

@zadjii-msft commented on GitHub (Feb 1, 2021):

@bbeckford If you'd like to "+1" this feature, the best way to do that is by hitting the 👍 button on this issue

image

That way, you avoid unnecessarily pinging everyone following this thread. Thanks!

@zadjii-msft commented on GitHub (Feb 1, 2021): @bbeckford If you'd like to "+1" this feature, the best way to do that is by hitting the 👍 button on this issue ![image](https://user-images.githubusercontent.com/18356694/96140789-ef3c8880-0ec5-11eb-82e0-30ce4977b9a7.png) That way, you avoid unnecessarily pinging everyone following this thread. Thanks!
Author
Owner

@markdomansky commented on GitHub (Feb 16, 2021):

I would like this for both tabs and panes. I encounter this issue with PowerShell. It will stop outputting data to the screen (unknown cause), or the remote sessions will get hosed because the temp files are deleted. Reconnecting the remote sessions don't work so restarting the shell seems to be the only fix. I also encounter this if PS or some other process inside starts consuming too much memory, or the shell becomes unresponsive due to whatever abuse I'm hurling at it. I tend to have consoles open for days, even weeks at a time, so this happens "regularly" for me.

@markdomansky commented on GitHub (Feb 16, 2021): I would like this for both tabs and panes. I encounter this issue with PowerShell. It will stop outputting data to the screen (unknown cause), or the remote sessions will get hosed because the temp files are deleted. Reconnecting the remote sessions don't work so restarting the shell seems to be the only fix. I also encounter this if PS or some other process inside starts consuming too much memory, or the shell becomes unresponsive due to whatever abuse I'm hurling at it. I tend to have consoles open for days, even weeks at a time, so this happens "regularly" for me.
Author
Owner

@SteffenBlake commented on GitHub (Aug 25, 2021):

If anyone is interested in a quick solution, I posted in #4379 a quick hack to get this functionality working in Windows Terminal here:

https://github.com/microsoft/terminal/issues/4379#issuecomment-905112832

@SteffenBlake commented on GitHub (Aug 25, 2021): If anyone is interested in a quick solution, I posted in #4379 a quick hack to get this functionality working in Windows Terminal here: https://github.com/microsoft/terminal/issues/4379#issuecomment-905112832
Author
Owner

@romero126 commented on GitHub (Jan 11, 2022):

I would love to see this particular feature prioritized. It's an incredible quality of life update that would drive a huge amount of impact from the users perspective.

@romero126 commented on GitHub (Jan 11, 2022): I would love to see this particular feature prioritized. It's an incredible quality of life update that would drive a huge amount of impact from the users perspective.
Author
Owner

@Rosefield commented on GitHub (Jan 11, 2022):

Its a bit of a stretch and might not be perfect, but with https://github.com/microsoft/terminal/issues/960 just merged, you could add the following action to "restart" a tab

        { 
          "command": {
            "action": "multipleActions",
            "actions": [ 
                "closeTab",
                "restoreLastClosed"
            ]
            },
          "name": "Restart tab"
        },

This does what it says and closes the tab and then creates a new tab with the same settings as the last closed tab. Replace closeTab with closePane if you want to restart a single pane (at the time of writing the closePane version is buggy and doesn't work as part of multipleActions as expected).

@Rosefield commented on GitHub (Jan 11, 2022): Its a bit of a stretch and might not be perfect, but with https://github.com/microsoft/terminal/issues/960 just merged, you could add the following action to "restart" a tab ``` { "command": { "action": "multipleActions", "actions": [ "closeTab", "restoreLastClosed" ] }, "name": "Restart tab" }, ``` This does what it says and closes the tab and then creates a new tab with the same settings as the last closed tab. Replace `closeTab` with `closePane` if you want to restart a single pane (at the time of writing the `closePane` version is buggy and doesn't work as part of multipleActions as expected).
Author
Owner

@vadimkantorov commented on GitHub (Jan 24, 2022):

My usecase from #12232 (dupe of this one):

"When ssh hangs in WSLv1 (usually because of network issues or after laptop sleep / hibernate), somehow it doesn't react to any Ctrl+C, Ctrl+Z. Then it's impossible to kill the ssh process, and it can take a few minutes for it to bail out by itself.

Current workaround: kill the whole tab (as it's impossible to kill the current process), open a new tab

Feature request: "reset a tab" command that will restart the tab (and preserve the tab's place in the tab bar).

Alternative feature request: somehow detecting the current process in the bash session and providing a command to kill it, e.g. it could kill all child processes except the original bash process PID."

@vadimkantorov commented on GitHub (Jan 24, 2022): My usecase from #12232 (dupe of this one): "When ssh hangs in WSLv1 (usually because of network issues or after laptop sleep / hibernate), somehow it doesn't react to any Ctrl+C, Ctrl+Z. Then it's impossible to kill the ssh process, and it can take a few minutes for it to bail out by itself. Current workaround: kill the whole tab (as it's impossible to kill the current process), open a new tab Feature request: "reset a tab" command that will restart the tab (and preserve the tab's place in the tab bar). Alternative feature request: somehow detecting the current process in the bash session and providing a command to kill it, e.g. it could kill all child processes except the original bash process PID."
Author
Owner

@swinder0161 commented on GitHub (Apr 13, 2022):

My usecase:
open an ssh session and start screen on that, start a job in screen and let it run.
I want to reload the ssh session so that screen can continue in background, and I come back to new ssh session in same tab
When ever I want I can go back to my screen from new session.

I know screen has option to exit without terminating, but being iterm user on mac, I find it more convenient to just reload the tab instead.

@swinder0161 commented on GitHub (Apr 13, 2022): My usecase: open an ssh session and start screen on that, start a job in screen and let it run. I want to reload the ssh session so that screen can continue in background, and I come back to new ssh session in same tab When ever I want I can go back to my screen from new session. I know screen has option to exit without terminating, but being iterm user on mac, I find it more convenient to just reload the tab instead.
Author
Owner

@swinder0161 commented on GitHub (Apr 13, 2022):

Its a bit of a stretch and might not be perfect, but with #960 just merged, you could add the following action to "restart" a tab

        { 
          "command": {
            "action": "multipleActions",
            "actions": [ 
                "closeTab",
                "restoreLastClosed"
            ]
            },
          "name": "Restart tab"
        },

This does what it says and closes the tab and then creates a new tab with the same settings as the last closed tab. Replace closeTab with closePane if you want to restart a single pane (at the time of writing the closePane version is buggy and doesn't work as part of multipleActions as expected).

The problem with this is the tab position is not restored, if tab closed is first one, the restored tab is the last one.
the position should also be restored

@swinder0161 commented on GitHub (Apr 13, 2022): > Its a bit of a stretch and might not be perfect, but with #960 just merged, you could add the following action to "restart" a tab > > ``` > { > "command": { > "action": "multipleActions", > "actions": [ > "closeTab", > "restoreLastClosed" > ] > }, > "name": "Restart tab" > }, > ``` > > This does what it says and closes the tab and then creates a new tab with the same settings as the last closed tab. Replace `closeTab` with `closePane` if you want to restart a single pane (at the time of writing the `closePane` version is buggy and doesn't work as part of multipleActions as expected). The problem with this is the tab position is not restored, if tab closed is first one, the restored tab is the last one. the position should also be restored
Author
Owner

@enria commented on GitHub (May 23, 2022):

Its a bit of a stretch and might not be perfect, but with #960 just merged, you could add the following action to "restart" a tab

        { 
          "command": {
            "action": "multipleActions",
            "actions": [ 
                "closeTab",
                "restoreLastClosed"
            ]
            },
          "name": "Restart tab"
        },

This does what it says and closes the tab and then creates a new tab with the same settings as the last closed tab. Replace closeTab with closePane if you want to restart a single pane (at the time of writing the closePane version is buggy and doesn't work as part of multipleActions as expected).

In case there is only one tab left, the whole window will be closed directly, and I found that this problem can be solved by split pane command.

        {
            "command": 
            {
                "action": "multipleActions",
                "actions": 
                [
                    {
                        "action": "splitPane",
                        "size":0.1,
                        "split": "up",
                        "splitMode":"duplicate"
                    },
                    {
                        "action": "moveFocus",
                        "direction": "previous"
                    },
                    {
                        "action": "closePane"
                    }

                ]
            },
            "keys": "ctrl+r",
            "name": "restart tab"
        }

I think this method is close to perfect, except when closing the pane, it shows the content behind the terminal, which may be a rendering engine issue. I made the newly added pane as large as possible (by setting size to 0.1) to minimize its impact.

In addition, the most important thing is that this method does not require an update to the preview version.

@enria commented on GitHub (May 23, 2022): > Its a bit of a stretch and might not be perfect, but with #960 just merged, you could add the following action to "restart" a tab > > ``` > { > "command": { > "action": "multipleActions", > "actions": [ > "closeTab", > "restoreLastClosed" > ] > }, > "name": "Restart tab" > }, > ``` > > This does what it says and closes the tab and then creates a new tab with the same settings as the last closed tab. Replace `closeTab` with `closePane` if you want to restart a single pane (at the time of writing the `closePane` version is buggy and doesn't work as part of multipleActions as expected). In case there is only one tab left, the whole window will be closed directly, and I found that this problem can be solved by `split pane` command. ```json { "command": { "action": "multipleActions", "actions": [ { "action": "splitPane", "size":0.1, "split": "up", "splitMode":"duplicate" }, { "action": "moveFocus", "direction": "previous" }, { "action": "closePane" } ] }, "keys": "ctrl+r", "name": "restart tab" } ``` I think this method is close to perfect, except when closing the pane, it shows the content behind the terminal, which may be a rendering engine issue. I made the newly added pane as large as possible (by setting `size` to 0.1) to minimize its impact. **In addition, the most important thing is that this method does not require an update to the preview version.**
Author
Owner

@DemoerDuan commented on GitHub (Aug 10, 2022):

I think

它有点牵强,可能并不完美,但#960刚刚合并,您可以添加以下操作来“重新启动”选项卡

        { 
          "command": {
            "action": "multipleActions",
            "actions": [ 
                "closeTab",
                "restoreLastClosed"
            ]
            },
          "name": "Restart tab"
        },

这会执行它所说的并关闭选项卡,然后创建一个与上次关闭的选项卡具有相同设置的新选项卡。如果要重新启动单个窗格,请替换closeTab为(在编写该版本时存在错误,并且不能按预期作为 multipleActions 的一部分工作)。closePane``closePane

如果只剩下一个tab,直接关闭整个窗口,我发现这个问题可以通过split pane命令解决。

        {
            "command": 
            {
                "action": "multipleActions",
                "actions": 
                [
                    {
                        "action": "splitPane",
                        "size":0.1,
                        "split": "up",
                        "splitMode":"duplicate"
                    },
                    {
                        "action": "moveFocus",
                        "direction": "previous"
                    },
                    {
                        "action": "closePane"
                    }

                ]
            },
            "keys": "ctrl+r",
            "name": "restart tab"
        }

我认为这种方法接近完美,除了关闭窗格时,它显示了终端后面的内容,这可能是渲染引擎的问题。我使新添加的窗格尽可能大(通过设置size为 0.1)以最大程度地减少其影响。

另外,最重要的是这种方法不需要更新到预览版。

Thanks for your answer! but I think it is not perfect, I just want to reopen this SSH quickly, but the "ctrl + r" will do 3 actions include spliting and closing the original pane ,and there is a dividing line will flash quickly.
image

@DemoerDuan commented on GitHub (Aug 10, 2022): I think > > 它有点牵强,可能并不完美,但#960刚刚合并,您可以添加以下操作来“重新启动”选项卡 > > ``` > > { > > "command": { > > "action": "multipleActions", > > "actions": [ > > "closeTab", > > "restoreLastClosed" > > ] > > }, > > "name": "Restart tab" > > }, > > ``` > > > > > > > > > > > > > > > > > > > > > > > > 这会执行它所说的并关闭选项卡,然后创建一个与上次关闭的选项卡具有相同设置的新选项卡。如果要重新启动单个窗格,请替换`closeTab`为(在编写该版本时存在错误,并且不能按预期作为 multipleActions 的一部分工作)。`closePane``closePane` > > 如果只剩下一个tab,直接关闭整个窗口,我发现这个问题可以通过`split pane`命令解决。 > > ```json > { > "command": > { > "action": "multipleActions", > "actions": > [ > { > "action": "splitPane", > "size":0.1, > "split": "up", > "splitMode":"duplicate" > }, > { > "action": "moveFocus", > "direction": "previous" > }, > { > "action": "closePane" > } > > ] > }, > "keys": "ctrl+r", > "name": "restart tab" > } > ``` > > 我认为这种方法接近完美,除了关闭窗格时,它显示了终端后面的内容,这可能是渲染引擎的问题。我使新添加的窗格尽可能大(通过设置`size`为 0.1)以最大程度地减少其影响。 > > **另外,最重要的是这种方法不需要更新到预览版。** Thanks for your answer! but I think it is not perfect, I just want to reopen this SSH quickly, but the "ctrl + r" will do 3 actions include spliting and closing the original pane ,and there is a dividing line will flash quickly. ![image](https://user-images.githubusercontent.com/55246033/183937819-90316aa8-a220-4cfb-b17e-12aa74e49405.png)
Author
Owner

@KanRobert commented on GitHub (Feb 13, 2023):

I found a solution (maybe perfect?)

        {
            "command": 
            {
                "action": "multipleActions",
                "actions": 
                [
                    "duplicateTab",
                    {
                        "action": "prevTab"
                    },
                    {
                        "action": "closeTab"
                    }
                ]
            },
            "keys": "ctrl+shift+r",
            "name": "Restart tab"
        }

and set "Position of newly created tabs" to "After current tab" in Appearance

@KanRobert commented on GitHub (Feb 13, 2023): I found a solution (maybe perfect?) ``` { "command": { "action": "multipleActions", "actions": [ "duplicateTab", { "action": "prevTab" }, { "action": "closeTab" } ] }, "keys": "ctrl+shift+r", "name": "Restart tab" } ``` and set "Position of newly created tabs" to "After current tab" in Appearance
Author
Owner

@hi2u commented on GitHub (Oct 26, 2023):

For anyone wanting to bind a key to the new restartConnection feature, this worked for me in my settings.json

{
    "$help": "https://aka.ms/terminal-documentation",
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": [
        {
            "command": "restartConnection",
            "keys": "alt+shift+r"
        }
    ]
}

The JSON schema seems to think it's invalid, but it works for me.

Looks like "$schema": "https://aka.ms/terminal-profiles-schema" needs to be updated to lint for it.

@hi2u commented on GitHub (Oct 26, 2023): For anyone wanting to bind a key to the new `restartConnection` feature, this worked for me in my `settings.json` ```json { "$help": "https://aka.ms/terminal-documentation", "$schema": "https://aka.ms/terminal-profiles-schema", "actions": [ { "command": "restartConnection", "keys": "alt+shift+r" } ] } ``` The JSON schema seems to think it's invalid, but it works for me. Looks like `"$schema": "https://aka.ms/terminal-profiles-schema"` needs to be updated to lint for it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5215