diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-04-11 06:44:40 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-04-11 06:44:40 +0000 |
commit | 6e49cd9dbffb1fe7d4dc633b5beda95ef575e793 (patch) | |
tree | 15a8422faf4dcb3b7e9faef3a557966a16aa73d0 /usr.bin/tmux | |
parent | cd6acbab36039ffe9683a9a91f9bcf249f805a9b (diff) |
Add -s option to detach all clients attached to a session, from Zac
Sprackett.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/cmd-detach-client.c | 32 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 11 |
2 files changed, 32 insertions, 11 deletions
diff --git a/usr.bin/tmux/cmd-detach-client.c b/usr.bin/tmux/cmd-detach-client.c index ed2f51dedf1..801ab7cf0c6 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.7 2011/03/03 08:51:47 nicm Exp $ */ +/* $OpenBSD: cmd-detach-client.c,v 1.8 2011/04/11 06:44:39 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -28,7 +28,7 @@ int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_detach_client_entry = { "detach-client", "detach", - "t:P", 0, 0, + "s:t:P", 0, 0, "[-P] " CMD_TARGET_CLIENT_USAGE, CMD_READONLY, NULL, @@ -41,14 +41,32 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; struct client *c; - - if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL) - return (-1); + struct session *s; + enum msgtype msgtype; + u_int i; if (args_has(args, 'P')) - server_write_client(c, MSG_DETACHKILL, NULL, 0); + msgtype = MSG_DETACHKILL; else - server_write_client(c, MSG_DETACH, NULL, 0); + msgtype = MSG_DETACH; + + if (args_has(args, 's')) { + s = cmd_find_session(ctx, args_get(args, 's'), 0); + if (s == NULL) + return (-1); + + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { + c = ARRAY_ITEM(&clients, i); + if (c != NULL && c->session == s) + server_write_client(c, msgtype, NULL, 0); + } + } else { + c = cmd_find_client(ctx, args_get(args, 't')); + if (c == NULL) + return (-1); + + server_write_client(c, msgtype, NULL, 0); + } return (0); } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 1bd84feb3b5..0b309fee334 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.217 2011/04/05 19:37:01 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.218 2011/04/11 06:44:39 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 5 2011 $ +.Dd $Mdocdate: April 11 2011 $ .Dt TMUX 1 .Os .Sh NAME @@ -576,10 +576,13 @@ session. .It Xo Ic detach-client .Op Fl P .Op Fl t Ar target-client +.Op Fl s Ar target-session .Xc .D1 (alias: Ic detach ) -Detach the current client if bound to a key, or the specified client with -.Fl t . +Detach the current client if bound to a key, the client specified with +.Fl t , +or all clients currently attached to to the session specified by +.Fl s . If .Fl P is given, send SIGHUP to the parent process of the client, typically causing it |