diff --git a/cmd-new-pane.c b/cmd-new-pane.c index a99180e7..02c2cdc4 100644 --- a/cmd-new-pane.c +++ b/cmd-new-pane.c @@ -35,9 +35,9 @@ const struct cmd_entry cmd_new_pane_entry = { .name = "new-pane", .alias = "newp", - .args = { "bc:de:fF:h:Il:p:Pt:w:x:y:Z", 0, -1, NULL }, - .usage = "[-bdefhIPvZ] [-c start-directory] [-e environment] " - "[-F format] [-l size] " CMD_TARGET_PANE_USAGE + .args = { "bc:de:fF:h:Iklm:p:Pt:w:x:y:Z", 0, -1, NULL }, + .usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] " + "[-F format] [-l size] [-m message] " CMD_TARGET_PANE_USAGE " [shell-command [argument ...]]", .target = { 't', CMD_FIND_PANE, 0 }, @@ -204,6 +204,12 @@ cmd_new_pane_exec(struct cmd *self, struct cmdq_item *item) environ_free(sc.environ); return (CMD_RETURN_ERROR); } + if (args_has(args, 'k') || args_has(args, 'm')) { + options_set_number(new_wp->options, "remain-on-exit", 3); + if (args_has(args, 'm')) + options_set_string(new_wp->options, "remain-on-exit-format", + 0, "%s", args_get(args, 'm')); + } if (input) { switch (window_pane_start_input(new_wp, item, &cause)) { case -1: diff --git a/options-table.c b/options-table.c index 39e5237b..6c9615f5 100644 --- a/options-table.c +++ b/options-table.c @@ -91,7 +91,7 @@ static const char *options_table_window_size_list[] = { "largest", "smallest", "manual", "latest", NULL }; static const char *options_table_remain_on_exit_list[] = { - "off", "on", "failed", NULL + "off", "on", "failed", "keypress", NULL }; static const char *options_table_destroy_unattached_list[] = { "off", "on", "keep-last", "keep-group", NULL @@ -1414,7 +1414,7 @@ const struct options_table_entry options_table[] = { { .name = "remain-on-exit-format", .type = OPTIONS_TABLE_STRING, .scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE, - .default_str = "Pane is dead (" + .default_str = "Command exited (" "#{?#{!=:#{pane_dead_status},}," "status #{pane_dead_status},}" "#{?#{!=:#{pane_dead_signal},}," diff --git a/server-client.c b/server-client.c index 4c5b398c..4d11c2cc 100644 --- a/server-client.c +++ b/server-client.c @@ -2665,6 +2665,14 @@ try_again: forward_key: if (c->flags & CLIENT_READONLY) goto out; + if (wp != NULL && + options_get_number(wp->options, "remain-on-exit") == 3 && + (wp->flags & PANE_EXITED) && + !KEYC_IS_MOUSE(key) && !KEYC_IS_PASTE(key)) { + options_set_number(wp->options, "remain-on-exit", 0); + server_destroy_pane(wp, 0); + goto out; + } if (wp != NULL) window_pane_key(wp, c, s, wl, key, m); goto out; diff --git a/server-fn.c b/server-fn.c index 986b8335..b08ebbf2 100644 --- a/server-fn.c +++ b/server-fn.c @@ -339,8 +339,11 @@ server_destroy_pane(struct window_pane *wp, int notify) switch (remain_on_exit) { case 0: break; + case 3: /* keypress — fall through to draw remain-on-exit-format message */ + /* FALLTHROUGH */ case 2: - if (WIFEXITED(wp->status) && WEXITSTATUS(wp->status) == 0) + if (remain_on_exit == 2 && + WIFEXITED(wp->status) && WEXITSTATUS(wp->status) == 0) break; /* FALLTHROUGH */ case 1: