mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Add a -f filter argument to the list commands like choose-tree.
This commit is contained in:
parent
70534cfde6
commit
756591b4ca
@ -36,8 +36,8 @@ const struct cmd_entry cmd_list_buffers_entry = {
|
|||||||
.name = "list-buffers",
|
.name = "list-buffers",
|
||||||
.alias = "lsb",
|
.alias = "lsb",
|
||||||
|
|
||||||
.args = { "F:", 0, 0 },
|
.args = { "F:f:", 0, 0 },
|
||||||
.usage = "[-F format]",
|
.usage = "[-F format] [-f filter]",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_list_buffers_exec
|
.exec = cmd_list_buffers_exec
|
||||||
@ -49,20 +49,30 @@ cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
char *line;
|
const char *template, *filter;
|
||||||
const char *template;
|
char *line, *expanded;
|
||||||
|
int flag;
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = LIST_BUFFERS_TEMPLATE;
|
template = LIST_BUFFERS_TEMPLATE;
|
||||||
|
filter = args_get(args, 'f');
|
||||||
|
|
||||||
pb = NULL;
|
pb = NULL;
|
||||||
while ((pb = paste_walk(pb)) != NULL) {
|
while ((pb = paste_walk(pb)) != NULL) {
|
||||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
||||||
format_defaults_paste_buffer(ft, pb);
|
format_defaults_paste_buffer(ft, pb);
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ const struct cmd_entry cmd_list_panes_entry = {
|
|||||||
.name = "list-panes",
|
.name = "list-panes",
|
||||||
.alias = "lsp",
|
.alias = "lsp",
|
||||||
|
|
||||||
.args = { "asF:t:", 0, 0 },
|
.args = { "asF:f:t:", 0, 0 },
|
||||||
.usage = "[-as] [-F format] " CMD_TARGET_WINDOW_USAGE,
|
.usage = "[-as] [-F format] [-f filter] " CMD_TARGET_WINDOW_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_WINDOW, 0 },
|
.target = { 't', CMD_FIND_WINDOW, 0 },
|
||||||
|
|
||||||
@ -91,8 +91,9 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
|
|||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
u_int n;
|
u_int n;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
const char *template;
|
const char *template, *filter;
|
||||||
char *line;
|
char *line, *expanded;
|
||||||
|
int flag;
|
||||||
|
|
||||||
template = args_get(args, 'F');
|
template = args_get(args, 'F');
|
||||||
if (template == NULL) {
|
if (template == NULL) {
|
||||||
@ -120,6 +121,7 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
filter = args_get(args, 'f');
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
|
||||||
@ -127,9 +129,17 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
|
|||||||
format_add(ft, "line", "%u", n);
|
format_add(ft, "line", "%u", n);
|
||||||
format_defaults(ft, NULL, s, wl, wp);
|
format_defaults(ft, NULL, s, wl, wp);
|
||||||
|
|
||||||
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);
|
||||||
n++;
|
n++;
|
||||||
|
@ -42,8 +42,8 @@ const struct cmd_entry cmd_list_sessions_entry = {
|
|||||||
.name = "list-sessions",
|
.name = "list-sessions",
|
||||||
.alias = "ls",
|
.alias = "ls",
|
||||||
|
|
||||||
.args = { "F:", 0, 0 },
|
.args = { "F:f:", 0, 0 },
|
||||||
.usage = "[-F format]",
|
.usage = "[-F format] [-f filter]",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_list_sessions_exec
|
.exec = cmd_list_sessions_exec
|
||||||
@ -56,11 +56,13 @@ cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
struct session *s;
|
struct session *s;
|
||||||
u_int n;
|
u_int n;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
const char *template;
|
const char *template, *filter;
|
||||||
char *line;
|
char *line, *expanded;
|
||||||
|
int flag;
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = LIST_SESSIONS_TEMPLATE;
|
template = LIST_SESSIONS_TEMPLATE;
|
||||||
|
filter = args_get(args, 'f');
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
@ -68,9 +70,17 @@ cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
format_add(ft, "line", "%u", n);
|
format_add(ft, "line", "%u", n);
|
||||||
format_defaults(ft, NULL, s, NULL, NULL);
|
format_defaults(ft, NULL, s, 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);
|
||||||
n++;
|
n++;
|
||||||
|
@ -49,8 +49,8 @@ const struct cmd_entry cmd_list_windows_entry = {
|
|||||||
.name = "list-windows",
|
.name = "list-windows",
|
||||||
.alias = "lsw",
|
.alias = "lsw",
|
||||||
|
|
||||||
.args = { "F:at:", 0, 0 },
|
.args = { "F:f:at:", 0, 0 },
|
||||||
.usage = "[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
|
.usage = "[-a] [-F format] [-f filter] " CMD_TARGET_SESSION_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.target = { 't', CMD_FIND_SESSION, 0 },
|
||||||
|
|
||||||
@ -88,8 +88,9 @@ cmd_list_windows_session(struct cmd *self, struct session *s,
|
|||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
u_int n;
|
u_int n;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
const char *template;
|
const char *template, *filter;
|
||||||
char *line;
|
char *line, *expanded;
|
||||||
|
int flag;
|
||||||
|
|
||||||
template = args_get(args, 'F');
|
template = args_get(args, 'F');
|
||||||
if (template == NULL) {
|
if (template == NULL) {
|
||||||
@ -102,6 +103,7 @@ cmd_list_windows_session(struct cmd *self, struct session *s,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
filter = args_get(args, 'f');
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
@ -109,9 +111,17 @@ cmd_list_windows_session(struct cmd *self, struct session *s,
|
|||||||
format_add(ft, "line", "%u", n);
|
format_add(ft, "line", "%u", n);
|
||||||
format_defaults(ft, NULL, s, wl, NULL);
|
format_defaults(ft, NULL, s, wl, 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);
|
||||||
n++;
|
n++;
|
||||||
|
36
tmux.1
36
tmux.1
@ -1055,12 +1055,18 @@ List the syntax of
|
|||||||
.Ar command
|
.Ar command
|
||||||
or - if omitted - of all commands supported by
|
or - if omitted - of all commands supported by
|
||||||
.Nm .
|
.Nm .
|
||||||
.It Ic list-sessions Op Fl F Ar format
|
.It Xo Ic list-sessions
|
||||||
|
.Op Fl F Ar format
|
||||||
|
.Op Fl f Ar filter
|
||||||
|
.Xc
|
||||||
.D1 (alias: Ic ls )
|
.D1 (alias: Ic ls )
|
||||||
List all sessions managed by the server.
|
List all sessions managed by 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 sessions for which the filter is true are shown.
|
||||||
|
See the
|
||||||
.Sx FORMATS
|
.Sx FORMATS
|
||||||
section.
|
section.
|
||||||
.It Ic lock-client Op Fl t Ar target-client
|
.It Ic lock-client Op Fl t Ar target-client
|
||||||
@ -2062,6 +2068,7 @@ is given, the newly linked window is not selected.
|
|||||||
.It Xo Ic list-panes
|
.It Xo Ic list-panes
|
||||||
.Op Fl as
|
.Op Fl as
|
||||||
.Op Fl F Ar format
|
.Op Fl F Ar format
|
||||||
|
.Op Fl f Ar filter
|
||||||
.Op Fl t Ar target
|
.Op Fl t Ar target
|
||||||
.Xc
|
.Xc
|
||||||
.D1 (alias: Ic lsp )
|
.D1 (alias: Ic lsp )
|
||||||
@ -2078,14 +2085,18 @@ is a session (or the current session).
|
|||||||
If neither is given,
|
If neither is given,
|
||||||
.Ar target
|
.Ar target
|
||||||
is a window (or the current window).
|
is a window (or the current window).
|
||||||
For the meaning of the
|
|
||||||
.Fl F
|
.Fl F
|
||||||
flag, see the
|
specifies the format of each line and
|
||||||
|
.Fl f
|
||||||
|
a filter.
|
||||||
|
Only panes for which the filter is true are shown.
|
||||||
|
See the
|
||||||
.Sx FORMATS
|
.Sx FORMATS
|
||||||
section.
|
section.
|
||||||
.It Xo Ic list-windows
|
.It Xo Ic list-windows
|
||||||
.Op Fl a
|
.Op Fl a
|
||||||
.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 (alias: Ic lsw )
|
.D1 (alias: Ic lsw )
|
||||||
@ -2094,9 +2105,12 @@ If
|
|||||||
is given, list all windows on the server.
|
is given, list all windows on the server.
|
||||||
Otherwise, list windows in the current session or in
|
Otherwise, list windows in the current session or in
|
||||||
.Ar target-session .
|
.Ar target-session .
|
||||||
For the meaning of the
|
|
||||||
.Fl F
|
.Fl F
|
||||||
flag, see the
|
specifies the format of each line and
|
||||||
|
.Fl f
|
||||||
|
a filter.
|
||||||
|
Only windows for which the filter is true are shown.
|
||||||
|
See the
|
||||||
.Sx FORMATS
|
.Sx FORMATS
|
||||||
section.
|
section.
|
||||||
.It Xo Ic move-pane
|
.It Xo Ic move-pane
|
||||||
@ -5261,12 +5275,16 @@ Delete the buffer named
|
|||||||
or the most recently added automatically named buffer if not specified.
|
or the most recently added automatically named buffer if not specified.
|
||||||
.It Xo Ic list-buffers
|
.It Xo Ic list-buffers
|
||||||
.Op Fl F Ar format
|
.Op Fl F Ar format
|
||||||
|
.Op Fl f Ar filter
|
||||||
.Xc
|
.Xc
|
||||||
.D1 (alias: Ic lsb )
|
.D1 (alias: Ic lsb )
|
||||||
List the global buffers.
|
List the global buffers.
|
||||||
For the meaning of the
|
|
||||||
.Fl F
|
.Fl F
|
||||||
flag, see the
|
specifies the format of each line and
|
||||||
|
.Fl f
|
||||||
|
a filter.
|
||||||
|
Only buffers for which the filter is true are shown.
|
||||||
|
See the
|
||||||
.Sx FORMATS
|
.Sx FORMATS
|
||||||
section.
|
section.
|
||||||
.It Xo Ic load-buffer
|
.It Xo Ic load-buffer
|
||||||
|
Loading…
Reference in New Issue
Block a user