From 623f4b12d3af7c6908c6abab1e95589c59f554ef Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 22 Feb 2018 10:54:51 +0000 Subject: Add exit-empty option to exit server if no sessions (defaults to on). --- options-table.c | 6 ++++++ server.c | 3 +++ tmux.1 | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/options-table.c b/options-table.c index c3363e48..20ac5d6f 100644 --- a/options-table.c +++ b/options-table.c @@ -97,6 +97,12 @@ const struct options_table_entry options_table[] = { .default_num = 500 }, + { .name = "exit-empty", + .type = OPTIONS_TABLE_FLAG, + .scope = OPTIONS_TABLE_SERVER, + .default_num = 1 + }, + { .name = "exit-unattached", .type = OPTIONS_TABLE_FLAG, .scope = OPTIONS_TABLE_SERVER, diff --git a/server.c b/server.c index 77ee9c36..b1d3312a 100644 --- a/server.c +++ b/server.c @@ -255,6 +255,9 @@ server_loop(void) server_client_loop(); + if (!options_get_number(global_options, "exit-empty") && !server_exit) + return (0); + if (!options_get_number(global_options, "exit-unattached")) { if (!RB_EMPTY(&sessions)) return (0); diff --git a/tmux.1 b/tmux.1 index 7eb228cb..428c1016 100644 --- a/tmux.1 +++ b/tmux.1 @@ -2503,6 +2503,11 @@ Set the time in milliseconds for which waits after an escape is input to determine if it is part of a function or meta key sequences. The default is 500 milliseconds. +.It Xo Ic exit-empty +.Op Ic on | off +.Xc +If enabled (the default), the server will exit when there are no active +sessions. .It Xo Ic exit-unattached .Op Ic on | off .Xc -- cgit From e97daead43800aedb3c1f1d50c92099d94e5ce13 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 22 Feb 2018 10:58:12 +0000 Subject: Check prefix when retrying so it is checked while repeat flag is set. GitHub issue 1239. --- server-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-client.c b/server-client.c index ee9472d3..d2c6ebf9 100644 --- a/server-client.c +++ b/server-client.c @@ -907,6 +907,7 @@ server_client_handle_key(struct client *c, key_code key) * The prefix always takes precedence and forces a switch to the prefix * table, unless we are already there. */ +retry: key0 = (key & ~KEYC_XTERM); if ((key0 == (key_code)options_get_number(s->options, "prefix") || key0 == (key_code)options_get_number(s->options, "prefix2")) && @@ -917,7 +918,6 @@ server_client_handle_key(struct client *c, key_code key) } flags = c->flags; -retry: /* Log key table. */ if (wp == NULL) log_debug("key table %s (no pane)", table->name); -- cgit