From 844f2eacf46842e18689f3b3ef464f67ea81dc61 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 9 Jan 2017 21:03:25 +0000 Subject: Add simple comparisons in formats: #{==:a,b} and #{!=:a,b} ("a" and "b" are expanded so can compare formats). And expand the condition to #{?a,b,c} (the "a" part) if it doesn't work as a simple lookup. Also add FORMAT_NOJOBS flag to disable jobs in a format. --- tmux.1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tmux.1') diff --git a/tmux.1 b/tmux.1 index a5be4617..04eb9de9 100644 --- a/tmux.1 +++ b/tmux.1 @@ -3397,6 +3397,21 @@ is enabled, or .Ql no if not. .Pp +Simple comparisons may be expressed by prefixing two comma-separated +alternatives by +.Ql == +or +.Ql != +and a colon. +For example +.Ql #{==,#{host},myhost} +will be replaced by +.Ql 1 +if running on +.Ql myhost , +otherwise by +.Ql 0. +.Pp A limit may be placed on the length of the resultant string by prefixing it by an .Ql = , -- cgit From d2d984647ee0149c6fc9ec4bcd8d109679208a27 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 9 Jan 2017 21:28:56 +0000 Subject: Add %if/%endif for conditionals when parsing configuration files, the argument is a format (the new == and != are useful). --- tmux.1 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tmux.1') diff --git a/tmux.1 b/tmux.1 index 04eb9de9..8f1a251f 100644 --- a/tmux.1 +++ b/tmux.1 @@ -930,6 +930,30 @@ If is given, no error will be returned if .Ar path does not exist. +.Pp +Within a configuration file, commands may be made conditional by surrounding +them with +.Em %if +and +.Em %endif +lines. +The argument to +.Em %if +is expanded as a format and if it evaluates to false +.Ns ( Ql 0 +or empty), subsequent lines are ignored until +.Em %endif . +For example: +.Bd -literal -offset indent +%if #{==:#{host},myhost} +set -g status-style bg=red +%endif +.Ed +.Pp +Will change the status line to red if running on +.Ql myhost . +.Em %if +may not be nested. .It Ic start-server .D1 (alias: Ic start ) Start the -- cgit