wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

Restarting dead panes with the same command

Open ipkiss42 opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. I started using Wezterm on Windows, to connect to a couple of remote hosts via SSH. For now I have one tab per host, with a single pane in each (I attach remote tmux sessions). After the connection is lost, panes are "dead": I can see the previous output (thanks to the CloseOnCleanExit behavior), but panes are inactive. So far so good.

The problem is to reconnect: new connections insist on using new tabs. This is annoying because:

  • I have to close the dead panes manually.
  • New tabs are created at the end, which messes with the ordering of the tabs (and thus I cannot rely on using ctrl-shift-N to always jump to the same tab).

Describe the solution you'd like I would like a simple way to restart a dead pane, i.e. reuse the same pane and re-run the program that was previously run in it.

This could be achieved via a new action which I can bind to a key. If the pane is not dead, the action would not do anything or would show a warning.

There could also be a button on dead panes to allow 1-click reuse.

Describe alternatives you've considered Current workaround described above.

Additional context N/A.

ipkiss42 avatar Jun 06 '22 13:06 ipkiss42

100% agree, note: I mentioned something like this in #580. Both issues need the same initial plumbing, allowing actions after a pane is dead. Once this is available (it's currently not AFAIK), both should be ~easy to implement I think.

I'd be great if it worked with wezterm ssh ... invocation as well, if it could restart the ssh connection. (there is no 'same command to restart' in this case, it's internal)

bew avatar Jun 06 '22 13:06 bew

There is a hacky way to "restart a tab" if you only want this for pre-defined commands and presuming the pane is not automically closed:

  1. When the current pane is dead, create a new pane in current tab.
  2. Run the command in new pane.
  3. Close the old pane.

If you want this to work with arbitrary commands, you will have to use user vars [1] to set/get the executed command. However, I am not sure if you can "get" it after the pane is dead (but before it's closed).

[1] https://wezfurlong.org/wezterm/config/lua/pane/get_user_vars.html

(2) Multiple actions with a single key press: https://wezfurlong.org/wezterm/config/lua/keyassignment/Multiple.html (3) Useful if there are multiple panes in a tab: https://wezfurlong.org/wezterm/config/lua/TabInformation.html

MuhammedZakir avatar Jun 06 '22 13:06 MuhammedZakir