=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-list-buffers.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- src/usr.bin/tmux/cmd-list-buffers.c 2017/05/01 12:20:55 1.35 +++ src/usr.bin/tmux/cmd-list-buffers.c 2020/04/12 08:36:18 1.36 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-buffers.c,v 1.35 2017/05/01 12:20:55 nicm Exp $ */ +/* $OpenBSD: cmd-list-buffers.c,v 1.36 2020/04/12 08:36:18 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -36,8 +36,8 @@ .name = "list-buffers", .alias = "lsb", - .args = { "F:", 0, 0 }, - .usage = "[-F format]", + .args = { "F:f:", 0, 0 }, + .usage = "[-F format] [-f filter]", .flags = CMD_AFTERHOOK, .exec = cmd_list_buffers_exec @@ -49,20 +49,30 @@ struct args *args = self->args; struct paste_buffer *pb; struct format_tree *ft; - char *line; - const char *template; + const char *template, *filter; + char *line, *expanded; + int flag; if ((template = args_get(args, 'F')) == NULL) template = LIST_BUFFERS_TEMPLATE; + filter = args_get(args, 'f'); pb = NULL; while ((pb = paste_walk(pb)) != NULL) { ft = format_create(item->client, item, FORMAT_NONE, 0); format_defaults_paste_buffer(ft, pb); - 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); }