I ssh into machines with shared config files but different tmux versions so I try to have a single version aware .tmux.conf. The following is for my tmux 2.6 machine.
My issue seems to be the nested ifs, or perhaps the nested quotes.
the following code hides the status bar when only one window is present:
if -F '#{==:#{session_windows},1}' 'set -g status off' 'set -g status on'; \
set-hook -g window-linked 'if -F "#{==:#{session_windows},1}" "set -g status off" "set -g status on"'; \
set-hook -g window-unlinked 'if -F "#{==:#{session_windows},1}" "set -g status off" "set -g status on"';
however my version guard, which adds double quotes around single quoted strings, breaks this
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.1" | bc)" = 1 ]' " \
if -F '#{==:#{session_windows},1}' 'set -g status off' 'set -g status on'; \
set-hook -g window-linked 'if -F "#{==:#{session_windows},1}" "set -g status off" "set -g status on"'; \
set-hook -g window-unlinked 'if -F "#{==:#{session_windows},1}" "set -g status off" "set -g status on"'; \
"
tmux starts up without any errors, but the status bar is not hidden.
You need to escape "
inside other "
as \"
.
Or put your inner commands in a separate config file and load it with source-file
.
If you were using a later tmux version you could use {}
to avoid this problem but on older tmux versions you will need to escape the quotes.