How to Setup Tmux Pane Synchronization Shortcut

Tmux comes in incredibly handy in multitude of situations, and one of them is when you are handling multiple ssh connections to pi devices or something akin to IoT devices. Assuming all the setup is already done on the local device, and this is part of your regular maintenance routine, logging in to each device every time can be time consuming and rather annoying.

What this how-to is trying to do is simple —with multiple panes already on the tmux, you might want to send the same key strokes to all the panes at the same time. For example, let’s say on two separate panes, you have ssh into two different pis and want to run simple update. Synchronize-pane effectively lets you control two devices at the same time.

Instructions

  1. Run following command on Terminal to edit tmux configuration:

sudo nano ~/.tmux.conf

(note: tmux may not have a configuration file at all, so do not be alarmed if the command creates a file, instead of editing it.)

  1. Add the following line:

bind C-x set-window-option synchronize-panes\; display-message "synchronize-panes is now #\{?pane\_synchronized,on,off}"

  1. Synchronize-pane is now bound to Ctrl+X. It is toggle-able, so the same key combination will turn it off as well.
  2. Restart tmux server:

tmux kill-server

You can change C-x to key combination of your liking. Don’t forget it needs to be preceded by the prefix, default is Ctrl+B.

Leave a comment