Tmux configuration stanzas based on Tmux version

terminaltmux

This question is loosely related to this one.

So I am using a range of Tmux versions between 1.5 and 2.2 on various operating systems (and Linux distros).

My ~/.tmux.conf which had been tailored to earlier versions shows the following three lines of warning on Tmux 2.2:

/home/username/.tmux.conf:34: unknown option: mode-mouse
/home/username/.tmux.conf:70: unknown option: status-utf8
/home/username/.tmux.conf:71: unknown option: utf8

A cursory look into the man page suggests that these configuration options have been discontinued. However, instead of silently ignoring them, Tmux complains about the "unknown" options.

The lines corresponding to the above warnings are:

set-window-option -g mode-mouse off
set-option -g status-utf8 on
set-window-option -g utf8 on

The option mode-mouse was discontinued in Tmux 2.1, status-utf8 and utf8 were discontinued in Tmux 2.2. The CHANGES file in the source tree details the options that have been removed, along with a brief description.

Is there a method by which I can suppress this output? Better yet, is it perhaps possible to conditionally execute configuration file stanzas based on the Tmux version without separate configuration file snippets (which would have to be source-d)?

In short: what's the straightforward way to use the exact same .tmux.conf across multiple Tmux versions?


Rationale: the reason this bothers me is that Tmux will show these warnings whenever a session gets started. And the it takes an action on my part (pressing a key) to get dropped into the shell. However, on older Tmux versions I do not have the problems, but I'd like to set the respective options on these older Tmux versions.


From the old man page:

status-utf8 [on | off]

Instruct tmux to treat top-bit-set characters
in the status-left and status-right strings as UTF-8; notably, this is
important for wide characters. This option defaults to off.

and:

utf8 [on | off]

Instructs tmux to expect UTF-8 sequences to appear in this window.

Best Answer

Is there a method by which I can suppress this output?

Yes. The set-option and set-window-option commands take a -q ("quiet") flag, which suppresses errors about unknown options. This should cover you:

set-window-option -gq mouse off
set-window-option -gq mode-mouse off
set-option -gq status-utf8 on
set-window-option -gq utf8 on
Related Question