From: nicm Date: Mon, 6 Feb 2023 09:20:30 +0000 (+0000) Subject: Add -f to list-clients like the other list commands, from Andy Walker in X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6c1aad9dfe4cce499a6aa0dec4bd783c4505783b;p=openbsd Add -f to list-clients like the other list commands, from Andy Walker in GitHub issue 3449. --- diff --git a/usr.bin/tmux/cmd-list-clients.c b/usr.bin/tmux/cmd-list-clients.c index f4187b0507b..2372ff83dd6 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.39 2022/03/08 11:28:40 nicm Exp $ */ +/* $OpenBSD: cmd-list-clients.c,v 1.40 2023/02/06 09:20:30 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -41,8 +41,8 @@ const struct cmd_entry cmd_list_clients_entry = { .name = "list-clients", .alias = "lsc", - .args = { "F:t:", 0, 0, NULL }, - .usage = "[-F format] " CMD_TARGET_SESSION_USAGE, + .args = { "F:f:t:", 0, 0, NULL }, + .usage = "[-F format] [-f filter] " CMD_TARGET_SESSION_USAGE, .target = { 't', CMD_FIND_SESSION, 0 }, @@ -58,9 +58,10 @@ cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item) struct client *c; struct session *s; struct format_tree *ft; - const char *template; + const char *template, *filter; u_int idx; - char *line; + char *line, *expanded; + int flag; if (args_has(args, 't')) s = target->s; @@ -69,6 +70,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item) if ((template = args_get(args, 'F')) == NULL) template = LIST_CLIENTS_TEMPLATE; + filter = args_get(args, 'f'); idx = 0; TAILQ_FOREACH(c, &clients, entry) { @@ -79,9 +81,17 @@ cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item) format_add(ft, "line", "%u", idx); format_defaults(ft, c, NULL, NULL, NULL); - line = format_expand(ft, template); - cmdq_print(item, "%s", line); - free(line); + if (filter != NULL) { + expanded = format_expand(ft, filter); + flag = format_true(expanded); + free(expanded); + } else + flag = 1; + if (flag) { + line = format_expand(ft, template); + cmdq_print(item, "%s", line); + free(line); + } format_free(ft); diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 29089e9f840..1155d62a696 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.914 2023/02/05 21:15:33 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.915 2023/02/06 09:20:30 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -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: February 5 2023 $ +.Dd $Mdocdate: February 6 2023 $ .Dt TMUX 1 .Os .Sh NAME @@ -1164,13 +1164,17 @@ session. .Tg lsc .It Xo Ic list-clients .Op Fl F Ar format +.Op Fl f Ar filter .Op Fl t Ar target-session .Xc .D1 Pq alias: Ic lsc List all clients attached to the server. -For the meaning of the .Fl F -flag, see the +specifies the format of each line and +.Fl f +a filter. +Only clients for which the filter is true are shown. +See the .Sx FORMATS section. If