How to Setup Tmux Pane Synchronization Shortcut
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
- 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.)
- Add the following line:
bind C-x set-window-option synchronize-panes\; display-message "synchronize-panes is now #\{?pane\_synchronized,on,off}"
- Synchronize-pane is now bound to
Ctrl+X
. It is toggle-able, so the same key combination will turn it off as well. - 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
.