diff options
Diffstat (limited to 'usr.bin/tmux/cmd-detach-client.c')
| -rw-r--r-- | usr.bin/tmux/cmd-detach-client.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/usr.bin/tmux/cmd-detach-client.c b/usr.bin/tmux/cmd-detach-client.c index b67dd3a7a8f..ade9447a79c 100644 --- a/usr.bin/tmux/cmd-detach-client.c +++ b/usr.bin/tmux/cmd-detach-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-detach-client.c,v 1.29 2016/10/16 19:04:05 nicm Exp $ */ +/* $OpenBSD: cmd-detach-client.c,v 1.30 2017/01/13 10:12:12 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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); } |
