mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 11:55:56 +00:00
Add -f to list-clients like the other list commands, from Andy Walker in
GitHub issue 3449.
This commit is contained in:
parent
0cb75f1332
commit
7acc8d703d
@ -41,8 +41,8 @@ const struct cmd_entry cmd_list_clients_entry = {
|
|||||||
.name = "list-clients",
|
.name = "list-clients",
|
||||||
.alias = "lsc",
|
.alias = "lsc",
|
||||||
|
|
||||||
.args = { "F:t:", 0, 0, NULL },
|
.args = { "F:f:t:", 0, 0, NULL },
|
||||||
.usage = "[-F format] " CMD_TARGET_SESSION_USAGE,
|
.usage = "[-F format] [-f filter] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.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 client *c;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
const char *template;
|
const char *template, *filter;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
char *line;
|
char *line, *expanded;
|
||||||
|
int flag;
|
||||||
|
|
||||||
if (args_has(args, 't'))
|
if (args_has(args, 't'))
|
||||||
s = target->s;
|
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)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = LIST_CLIENTS_TEMPLATE;
|
template = LIST_CLIENTS_TEMPLATE;
|
||||||
|
filter = args_get(args, 'f');
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
TAILQ_FOREACH(c, &clients, entry) {
|
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_add(ft, "line", "%u", idx);
|
||||||
format_defaults(ft, c, NULL, NULL, NULL);
|
format_defaults(ft, c, NULL, NULL, NULL);
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
if (filter != NULL) {
|
||||||
cmdq_print(item, "%s", line);
|
expanded = format_expand(ft, filter);
|
||||||
free(line);
|
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);
|
format_free(ft);
|
||||||
|
|
||||||
|
8
tmux.1
8
tmux.1
@ -1164,13 +1164,17 @@ session.
|
|||||||
.Tg lsc
|
.Tg lsc
|
||||||
.It Xo Ic list-clients
|
.It Xo Ic list-clients
|
||||||
.Op Fl F Ar format
|
.Op Fl F Ar format
|
||||||
|
.Op Fl f Ar filter
|
||||||
.Op Fl t Ar target-session
|
.Op Fl t Ar target-session
|
||||||
.Xc
|
.Xc
|
||||||
.D1 Pq alias: Ic lsc
|
.D1 Pq alias: Ic lsc
|
||||||
List all clients attached to the server.
|
List all clients attached to the server.
|
||||||
For the meaning of the
|
|
||||||
.Fl F
|
.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
|
.Sx FORMATS
|
||||||
section.
|
section.
|
||||||
If
|
If
|
||||||
|
Loading…
Reference in New Issue
Block a user