From 3e72e98e3bdf3e814d6d20060247bb5f5dc859bb Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 13 Jun 2019 19:46:00 +0000 Subject: Add regular expression support for the format search, match and substitute modifiers. --- tmux.1 | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) (limited to 'tmux.1') diff --git a/tmux.1 b/tmux.1 index 9f97422c..21a30fff 100644 --- a/tmux.1 +++ b/tmux.1 @@ -4012,25 +4012,45 @@ if running on .Ql myhost , otherwise by .Ql 0 . -An -.Ql m -specifies an -.Xr fnmatch 3 -comparison where the first argument is the pattern and the second the string to -compare, for example -.Ql #{m:*foo*,#{host}} . .Ql || and .Ql && evaluate to true if either or both of two comma-separated alternatives are true, for example .Ql #{||:#{pane_in_mode},#{alternate_on}} . +.Pp +An +.Ql m +specifies an +.Xr fnmatch 3 +or regular expression comparison. +The first argument is the pattern and the second the string to compare. +An optional third argument specifies flags: +.Ql r +means the pattern is a regular expression instead of the default +.Xr fnmatch 3 +pattern, and +.Ql i +means to ignore case. +For example: +.Ql #{m:*foo*,#{host}} +or +.Ql #{m/ri:^A,MYVAR} . A .Ql C performs a search for an .Xr fnmatch 3 -pattern in the pane content and evaluates to zero if not found, or a line -number if found. +pattern or regular expression in the pane content and evaluates to zero if not +found, or a line number if found. +Like +.Ql m , +a +.Ql r +flag means search for a regular expression and +.Ql i +ignores case. +For example: +.Ql #{C/r:^Start} .Pp A limit may be placed on the length of the resultant string by prefixing it by an @@ -4103,6 +4123,14 @@ will substitute with .Ql bar throughout. +The first argument may be an extended regular expression and a final argument may be +.Ql i +to ignore case, for example +.Ql s/a(.)/\1x/i: +would change +.Ql abABab +into +.Ql bxBxbx . .Pp In addition, the first line of a shell command's output may be inserted using .Ql #() . -- cgit From b8a9c740bbb0f28ce7cbfeeec584e0719950b8a8 Mon Sep 17 00:00:00 2001 From: jmc Date: Thu, 13 Jun 2019 21:04:21 +0000 Subject: tweak previous; --- tmux.1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tmux.1') diff --git a/tmux.1 b/tmux.1 index 21a30fff..e5d837da 100644 --- a/tmux.1 +++ b/tmux.1 @@ -4044,7 +4044,7 @@ pattern or regular expression in the pane content and evaluates to zero if not found, or a line number if found. Like .Ql m , -a +an .Ql r flag means search for a regular expression and .Ql i @@ -4126,7 +4126,7 @@ throughout. The first argument may be an extended regular expression and a final argument may be .Ql i to ignore case, for example -.Ql s/a(.)/\1x/i: +.Ql s/a(.)/\e1x/i: would change .Ql abABab into -- cgit From 45203582ff8708042c5f4f7134ad7d4ec71d2050 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 14 Jun 2019 12:04:11 +0000 Subject: A couple of minor parser changes around conditions: 1) only treat #{ specially after a condition, otherwise as a comment (which is more as most people expect) 2) allow formats to be quoted after a condition. --- tmux.1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tmux.1') diff --git a/tmux.1 b/tmux.1 index e5d837da..041097b6 100644 --- a/tmux.1 +++ b/tmux.1 @@ -582,9 +582,9 @@ or .Ql %endif . For example: .Bd -literal -offset indent -%if #{==:#{host},myhost} +%if "#{==:#{host},myhost}" set -g status-style bg=red -%elif #{==:#{host},myotherhost} +%elif "#{==:#{host},myotherhost}" set -g status-style bg=green %else set -g status-style bg=blue -- cgit