Restart on Exit

Press one key to rerun a profile's command in the same pane, with the scrollback kept, after it exits.

When a pane's command exits and the pane is held open (wait-after-command), the exit notice offers to rerun it: press the restart key and the same command starts again in the same pane, with everything already on screen kept where it was. Any other key closes the pane, as before.

This is built for the pattern where a pane runs one command rather than an interactive shell — an SSH session to a dev box that dies when the laptop sleeps, a cmd /c build script, a tail job. Rerunning it is one keypress instead of opening a new tab and picking the profile again, and the output from the previous run stays above the new one.

It is opt-in and per profile. A profile that does not set it keeps the old notice (Process exited. Press any key to close the terminal.) and the old behavior.

Enabling It

Add the Wintty-only restart-on-exit key to the profile:

profile.devbox.name = DevBox
profile.devbox.command = ssh me@devbox
profile.devbox.restart-on-exit = true

With that set, a pane running that profile shows:

Process exited. Press Enter to restart, any other key to close.

Press Enter and the profile's command starts again in the same pane. The new run's output appears below the old run's output and the exit notice; the scrollback is not cleared. Splits opened from the pane inherit the setting; panes with no profile, and -e / initial-command panes, never offer a restart.

Choosing the Key

The key is global and defaults to Enter. Change it with restart-on-exit-key to any single key or chord, written the same way as a keybind trigger:

restart-on-exit-key = ctrl+r

The notice names the key it will act on, so a chord reads Press Ctrl+R to restart. The offered key wins over anything else the same chord is bound to — including the app's own Windows chords like ctrl+shift+z — for as long as the notice is on screen.

Values the pane can never receive fall back to Enter with a warning in the log: a bare uppercase letter or punctuation (X, ?, +), a modifier on its own (ctrl), catch_all, a lock-modifier chord (caps_lock+enter), alt+space (owned by the system menu), and a modifier key as the trigger (left_shift). A config reload changes the key for the next exit; a notice already on screen keeps the key it printed.

Note

restart-on-exit-key is a libghostty option and appears in the Option Reference. It does nothing without profile.<id>.restart-on-exit.