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

Implement a keybinding to restart/reload a tab #3726

Closed
matt-beamish opened this issue Nov 27, 2019 · 19 comments · Fixed by #15241
Closed

Implement a keybinding to restart/reload a tab #3726

matt-beamish opened this issue Nov 27, 2019 · 19 comments · Fixed by #15241
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) In-PR This issue has a related PR Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Milestone

Comments

@matt-beamish
Copy link

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

@matt-beamish matt-beamish added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Nov 27, 2019
@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 27, 2019
@zadjii-msft zadjii-msft added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Nov 27, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Nov 27, 2019
@zadjii-msft
Copy link
Member

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

@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Nov 27, 2019
@DHowett-MSFT DHowett-MSFT removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Nov 30, 2019
@dominik-ba
Copy link
Contributor

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.

@DHowett
Copy link
Member

DHowett commented 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?

@dominik-ba
Copy link
Contributor

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 :)

@zadjii-msft
Copy link
Member

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

@dseven
Copy link

dseven commented 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.

@bbeckford

This comment has been minimized.

@zadjii-msft

This comment has been minimized.

@markdomansky
Copy link

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.

@SteffenBlake
Copy link

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

#4379 (comment)

@zadjii-msft zadjii-msft modified the milestones: Terminal Backlog, Backlog Jan 4, 2022
@romero126
Copy link

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.

@Rosefield
Copy link
Contributor

Rosefield commented Jan 11, 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).

@vadimkantorov
Copy link

vadimkantorov commented 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."

@swinder0161
Copy link

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
Copy link

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

@enria
Copy link

enria commented 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.

@DemoerDuan
Copy link

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

@ghost ghost added the In-PR This issue has a related PR label Dec 13, 2022
@KanRobert
Copy link

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

DHowett pushed a commit that referenced this issue Apr 28, 2023
Adds an action for immediately restarting the connection. I suspect
most folks that wanted #3726 will be happy just with the
<kbd>enter</kbd> solution from #14060, but this will work without having
to `exit` the client. Just, relaunch whatever the commandline is. Easy
peasy.

Closes #3726.

Obsoletes #14549
@hi2u
Copy link

hi2u commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) In-PR This issue has a related PR 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

Successfully merging a pull request may close this issue.