diff options
author | nicm <nicm> | 2017-01-13 10:12:12 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-01-13 10:12:12 +0000 |
commit | 95950bf668cee5a80cd9bbe28d7134a52a240426 (patch) | |
tree | 37618ea72fabbd151d60519139e9d816124ca170 /cmd-detach-client.c | |
parent | 24cba5907b5006363ac7f83f31801153f9c23b37 (diff) | |
download | rtmux-95950bf668cee5a80cd9bbe28d7134a52a240426.tar.gz rtmux-95950bf668cee5a80cd9bbe28d7134a52a240426.tar.bz2 rtmux-95950bf668cee5a80cd9bbe28d7134a52a240426.zip |
Add -E to detach-client to exec a command to replace the client instead
of exiting it, useful if tmux wasn't exec'd itself. From Jenna Magius.
Diffstat (limited to 'cmd-detach-client.c')
-rw-r--r-- | cmd-detach-client.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/cmd-detach-client.c b/cmd-detach-client.c index 69225bae..a10fd42a 100644 --- a/cmd-detach-client.c +++ b/cmd-detach-client.c @@ -33,8 +33,9 @@ const struct cmd_entry cmd_detach_client_entry = { .name = "detach-client", .alias = "detach", - .args = { "as:t:P", 0, 0 }, - .usage = "[-P] [-a] [-s target-session] " CMD_TARGET_CLIENT_USAGE, + .args = { "aE:s:t:P", 0, 0 }, + .usage = "[-aP] [-E shell-command] " + "[-s target-session] " CMD_TARGET_CLIENT_USAGE, .sflag = CMD_SESSION, .tflag = CMD_CLIENT, @@ -63,6 +64,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item) struct client *c = item->state.c, *cloop; struct session *s; enum msgtype msgtype; + const char *cmd = args_get(args, 'E'); if (self->entry == &cmd_suspend_client_entry) { tty_stop_tty(&c->tty); @@ -79,20 +81,31 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item) if (args_has(args, 's')) { s = item->state.sflag.s; TAILQ_FOREACH(cloop, &clients, entry) { - if (cloop->session == s) - server_client_detach(cloop, msgtype); + if (cloop->session == s) { + if (cmd != NULL) + server_client_exec(cloop, cmd); + else + server_client_detach(cloop, msgtype); + } } return (CMD_RETURN_STOP); } if (args_has(args, 'a')) { TAILQ_FOREACH(cloop, &clients, entry) { - if (cloop->session != NULL && cloop != c) - server_client_detach(cloop, msgtype); + if (cloop->session != NULL && cloop != c) { + if (cmd != NULL) + server_client_exec(cloop, cmd); + else + server_client_detach(cloop, msgtype); + } } return (CMD_RETURN_NORMAL); } - server_client_detach(c, msgtype); + if (cmd != NULL) + server_client_exec(c, cmd); + else + server_client_detach(c, msgtype); return (CMD_RETURN_STOP); } |