From 34a331aa9928619dc095b4daacdeed379e73ffbe Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 18 Apr 2011 21:07:12 +0000 Subject: [PATCH] |PatchSet 891 |Date: 2011/04/17 20:28:09 |Author: nicm |Branch: HEAD |Tag: (none) |Log: |Add -t to list-clients, based on a diff from Zac Sprackett. --- cmd-list-clients.c | 20 ++++++++++++++++---- tmux.1 | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cmd-list-clients.c b/cmd-list-clients.c index 97bf02bc..88073e8f 100644 --- a/cmd-list-clients.c +++ b/cmd-list-clients.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-clients.c,v 1.21 2011-01-07 14:45:34 tcunha Exp $ */ +/* $Id: cmd-list-clients.c,v 1.22 2011-04-18 21:07:11 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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/tmux.1 b/tmux.1 index 69dde872..cb71422c 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1,4 +1,4 @@ -.\" $Id: tmux.1,v 1.306 2011-04-18 21:06:25 nicm Exp $ +.\" $Id: tmux.1,v 1.307 2011-04-18 21:07:12 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\"