diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-06-20 20:31:05 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-06-20 20:31:05 +0000 |
commit | 094c28cc6e82ee5fc11aa09e3d18f202feeaa848 (patch) | |
tree | f26a793b6c5390a9b0b236cdc9317b2fb2b57b2f /usr.bin | |
parent | 76d1adc5a55fa280df3075921950308081859882 (diff) |
Add -r to find-window for regex instead of fnmatch.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-find-window.c | 83 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 10 |
2 files changed, 62 insertions, 31 deletions
diff --git a/usr.bin/tmux/cmd-find-window.c b/usr.bin/tmux/cmd-find-window.c index 9efa1912216..68e0db91132 100644 --- a/usr.bin/tmux/cmd-find-window.c +++ b/usr.bin/tmux/cmd-find-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-find-window.c,v 1.45 2018/08/20 15:00:42 nicm Exp $ */ +/* $OpenBSD: cmd-find-window.c,v 1.46 2019/06/20 20:31:04 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -32,8 +32,8 @@ const struct cmd_entry cmd_find_window_entry = { .name = "find-window", .alias = "findw", - .args = { "CNt:TZ", 1, 1 }, - .usage = "[-CNTZ] " CMD_TARGET_PANE_USAGE " match-string", + .args = { "CNrt:TZ", 1, 1 }, + .usage = "[-CNrTZ] " CMD_TARGET_PANE_USAGE " match-string", .target = { 't', CMD_FIND_PANE, 0 }, @@ -57,30 +57,59 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item) if (!C && !N && !T) C = N = T = 1; - if (C && N && T) { - xasprintf(&filter, - "#{||:" - "#{C:%s},#{||:#{m:*%s*,#{window_name}}," - "#{m:*%s*,#{pane_title}}}}", - s, s, s); - } else if (C && N) { - xasprintf(&filter, - "#{||:#{C:%s},#{m:*%s*,#{window_name}}}", - s, s); - } else if (C && T) { - xasprintf(&filter, - "#{||:#{C:%s},#{m:*%s*,#{pane_title}}}", - s, s); - } else if (N && T) { - xasprintf(&filter, - "#{||:#{m:*%s*,#{window_name}},#{m:*%s*,#{pane_title}}}", - s, s); - } else if (C) - xasprintf(&filter, "#{C:%s}", s); - else if (N) - xasprintf(&filter, "#{m:*%s*,#{window_name}}", s); - else - xasprintf(&filter, "#{m:*%s*,#{pane_title}}", s); + if (!args_has(args, 'r')) { + if (C && N && T) { + xasprintf(&filter, + "#{||:" + "#{C:%s},#{||:#{m:*%s*,#{window_name}}," + "#{m:*%s*,#{pane_title}}}}", + s, s, s); + } else if (C && N) { + xasprintf(&filter, + "#{||:#{C:%s},#{m:*%s*,#{window_name}}}", + s, s); + } else if (C && T) { + xasprintf(&filter, + "#{||:#{C:%s},#{m:*%s*,#{pane_title}}}", + s, s); + } else if (N && T) { + xasprintf(&filter, + "#{||:#{m:*%s*,#{window_name}}," + "#{m:*%s*,#{pane_title}}}", + s, s); + } else if (C) + xasprintf(&filter, "#{C:%s}", s); + else if (N) + xasprintf(&filter, "#{m:*%s*,#{window_name}}", s); + else + xasprintf(&filter, "#{m:*%s*,#{pane_title}}", s); + } else { + if (C && N && T) { + xasprintf(&filter, + "#{||:" + "#{C/r:%s},#{||:#{m/r:%s,#{window_name}}," + "#{m/r:%s,#{pane_title}}}}", + s, s, s); + } else if (C && N) { + xasprintf(&filter, + "#{||:#{C/r:%s},#{m/r:%s,#{window_name}}}", + s, s); + } else if (C && T) { + xasprintf(&filter, + "#{||:#{C/r:%s},#{m/r:%s,#{pane_title}}}", + s, s); + } else if (N && T) { + xasprintf(&filter, + "#{||:#{m/r:%s,#{window_name}}," + "#{m/r:%s,#{pane_title}}}", + s, s); + } else if (C) + xasprintf(&filter, "#{C/r:%s}", s); + else if (N) + xasprintf(&filter, "#{m/r:%s,#{window_name}}", s); + else + xasprintf(&filter, "#{m/r:%s,#{pane_title}}", s); + } new_args = args_parse("", 1, &argv); if (args_has(args, 'Z')) diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index cd89e3275f5..98ef3e0db5b 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.669 2019/06/20 13:40:22 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.670 2019/06/20 20:31:04 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -1828,14 +1828,16 @@ With .Fl b , other commands are not blocked from running until the indicator is closed. .It Xo Ic find-window -.Op Fl CNTZ +.Op Fl rCNTZ .Op Fl t Ar target-pane .Ar match-string .Xc .D1 (alias: Ic findw ) -Search for the +Search for a .Xr fnmatch 3 -pattern +pattern or, with +.Fl r , +regular expression .Ar match-string in window names, titles, and visible content (but not history). The flags control matching behavior: |