Add remain-on-exit key to keep pane around until a key is pressed, from

Michael Grant.
This commit is contained in:
nicm
2026-04-04 17:00:33 +00:00
parent 87aaff5fae
commit 7f2ac9c871
4 changed files with 18 additions and 4 deletions

View File

@@ -92,7 +92,7 @@ static const char *options_table_window_size_list[] = {
"largest", "smallest", "manual", "latest", NULL "largest", "smallest", "manual", "latest", NULL
}; };
static const char *options_table_remain_on_exit_list[] = { static const char *options_table_remain_on_exit_list[] = {
"off", "on", "failed", NULL "off", "on", "failed", "key", NULL
}; };
static const char *options_table_destroy_unattached_list[] = { static const char *options_table_destroy_unattached_list[] = {
"off", "on", "keep-last", "keep-group", NULL "off", "on", "keep-last", "keep-group", NULL
@@ -1408,8 +1408,9 @@ const struct options_table_entry options_table[] = {
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE, .scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,
.choices = options_table_remain_on_exit_list, .choices = options_table_remain_on_exit_list,
.default_num = 0, .default_num = 0,
.text = "Whether panes should remain ('on') or be automatically " .text = "Whether panes should remain ('on'), remain until a key is "
"killed ('off' or 'failed') when the program inside exits." "pressed ('key') or be automatically killed ('off' or "
"'failed') when the program inside exits."
}, },
{ .name = "remain-on-exit-format", { .name = "remain-on-exit-format",

View File

@@ -1359,6 +1359,15 @@ try_again:
} }
forward_key: forward_key:
if (wp != NULL &&
(wp->flags & PANE_EXITED) &&
!KEYC_IS_MOUSE(key) &&
!KEYC_IS_PASTE(key) &&
options_get_number(wp->options, "remain-on-exit") == 3) {
options_set_number(wp->options, "remain-on-exit", 0);
server_destroy_pane(wp, 0);
goto out;
}
if (c->flags & CLIENT_READONLY) if (c->flags & CLIENT_READONLY)
goto out; goto out;
if (wp != NULL) if (wp != NULL)

View File

@@ -341,6 +341,7 @@ server_destroy_pane(struct window_pane *wp, int notify)
break; break;
/* FALLTHROUGH */ /* FALLTHROUGH */
case 1: case 1:
case 3:
if (wp->flags & PANE_STATUSDRAWN) if (wp->flags & PANE_STATUSDRAWN)
return; return;
wp->flags |= PANE_STATUSDRAWN; wp->flags |= PANE_STATUSDRAWN;

5
tmux.1
View File

@@ -5569,13 +5569,16 @@ uses when the colour with that index is requested.
The index may be from zero to 255. The index may be from zero to 255.
.Pp .Pp
.It Xo Ic remain\-on\-exit .It Xo Ic remain\-on\-exit
.Op Ic on | off | failed .Op Ic on | off | failed | key
.Xc .Xc
A pane with this flag set is not destroyed when the program running in it A pane with this flag set is not destroyed when the program running in it
exits. exits.
If set to If set to
.Ic failed , .Ic failed ,
then only when the program exit status is not zero. then only when the program exit status is not zero.
If set to
.Ic key ,
the pane stays open and closes when a key is pressed.
The pane may be reactivated with the The pane may be reactivated with the
.Ic respawn\-pane .Ic respawn\-pane
command. command.