diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-04-17 19:28:10 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-04-17 19:28:10 +0000 |
commit | 8467578a34caee4c1fbf5876e72aea010d481b58 (patch) | |
tree | 7dd0af16ab3cb4f745eda4face8f93f6b8b8f97c /usr.bin/tmux | |
parent | a78dd7f67f6d475bceba7f1eb1a530162a1d6909 (diff) |
Add -t to list-clients, based on a diff from Zac Sprackett.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/cmd-list-clients.c | 20 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 10 |
2 files changed, 22 insertions, 8 deletions
diff --git a/usr.bin/tmux/cmd-list-clients.c b/usr.bin/tmux/cmd-list-clients.c index 182b4277412..5822ce424a3 100644 --- a/usr.bin/tmux/cmd-list-clients.c +++ b/usr.bin/tmux/cmd-list-clients.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-clients.c,v 1.6 2011/01/04 00:42:46 nicm Exp $ */ +/* $OpenBSD: cmd-list-clients.c,v 1.7 2011/04/17 19:28:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,8 +31,8 @@ int cmd_list_clients_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_list_clients_entry = { "list-clients", "lsc", - "", 0, 0, - "", + "t:", 0, 0, + CMD_TARGET_SESSION_USAGE, 0, NULL, NULL, @@ -41,12 +41,21 @@ const struct cmd_entry cmd_list_clients_entry = { /* ARGSUSED */ int -cmd_list_clients_exec(unused struct cmd *self, struct cmd_ctx *ctx) +cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx) { + struct args *args = self->args; struct client *c; + struct session *s; u_int i; const char *s_utf8; + if (args_has(args, 't')) { + s = cmd_find_session(ctx, args_get(args, 't'), 0); + if (s == NULL) + return (-1); + } else + s = NULL; + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { c = ARRAY_ITEM(&clients, i); if (c == NULL || c->session == NULL) @@ -56,6 +65,9 @@ cmd_list_clients_exec(unused struct cmd *self, struct cmd_ctx *ctx) s_utf8 = " (utf8)"; else s_utf8 = ""; + + if (s != NULL && s != c->session) + continue; ctx->print(ctx, "%s: %s [%ux%u %s]%s", c->tty.path, c->session->name, c->tty.sx, c->tty.sy, c->tty.termname, s_utf8); diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 26f9d1e7411..76eeb936e30 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.219 2011/04/11 16:44:36 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.220 2011/04/17 19:28:09 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 11 2011 $ +.Dd $Mdocdate: April 17 2011 $ .Dt TMUX 1 .Os .Sh NAME @@ -598,9 +598,11 @@ server and clients and destroy all sessions. .It Ic kill-session Op Fl t Ar target-session Destroy the given session, closing any windows linked to it and no other sessions, and detaching all clients attached to it. -.It Ic list-clients +.It Ic list-clients Op Fl t Ar target-session .D1 (alias: Ic lsc ) -List all clients attached to the server. +List all clients attached to the server. If +.Ar target-session +is specified, list only clients connected to that session. .It Ic list-commands .D1 (alias: Ic lscm ) List the syntax of all commands supported by |