summaryrefslogtreecommitdiffstats
path: root/cmd-list-clients.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 03:34:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 03:34:56 +0000
commitc294c2bf54a3ec56271a78c284f84e75a8119731 (patch)
treef1fed2d81b80619666e9508fa5051bcfc34fae5f /cmd-list-clients.c
parentReleasing progress-linux version 3.3a-5~progress7.99u1. (diff)
downloadtmux-c294c2bf54a3ec56271a78c284f84e75a8119731.tar.xz
tmux-c294c2bf54a3ec56271a78c284f84e75a8119731.zip
Merging upstream version 3.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmd-list-clients.c')
-rw-r--r--cmd-list-clients.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/cmd-list-clients.c b/cmd-list-clients.c
index 53a9917..da7541b 100644
--- a/cmd-list-clients.c
+++ b/cmd-list-clients.c
@@ -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);