tmux: how to toggle "on" and "off" options with the same key

facha picture facha · Sep 18, 2014 · Viewed 13k times · Source

This is a bit of my tmux.conf

cat tmux.conf
...
bind a set-window-option synchronize-panes on
bind b set-window-option synchronize-panes off

As you can see, sync and unsync options for panes are bound to two different keys. Is it possible to toggle sync/unsync with the same key?

Answer

Ojp picture Ojp · Nov 6, 2014

If you don't explicitly specify "on" or "off", the option will get toggled. The following would suffice:

bind-key a set-window-option synchronize-panes\; display-message "synchronize-panes is now #{?pane_synchronized,on,off}"