In tmux I have a 3 columns and 2 rows layout, the top row is ssh connection to all my server and the bottom is all the same servers running top.
I am trying to sync the top row so if I enter a command all three panes copy the same command, I tried synchronize-panes but as the man pages says it will run the commands through all the panes which then plays havoc with my all my 'top' on the botton row.
is there anyway to sync a set of panes?
It's not exactly what you're looking for but it is pretty close. The idea is to bind a key to a set of commands to:
Here is how the command looks like
bind R command-prompt -p "Command :" "select-pane -t 0 \; send-keys "%1" C-m \; select-pane -t 2 \; send-keys "%1" C-m \; select-pane -t 4 \; send-keys "%1" C-m "
Following is a complete example, let's setup the 6 panes, 2 rows of 3 each :
$ tmux new -s 'top_n_tail' \; split-window -h \; split-window -h \; select-layout even-horizontal \; detach
$ tmux att -t 'top_n_tail' \; select-pane -t 0 \; split-window \; detach
$ tmux att -t 'top_n_tail' \; select-pane -t 2 \; split-window \; detach
$ tmux att -t 'top_n_tail' \; select-pane -t 4 \; split-window
On tmux prompt (C-b :) bind 'R' to a set of tmux commands which accept your bash command and send it to some panes:
:bind R command-prompt -p "Command :" "select-pane -t 0 \; send-keys "%1" C-m \; select-pane -t 2 \; send-keys "%1" C-m \; select-pane -t 4 \; send-keys "%1" C-m "
Now when you hit C-b R, you'll be prompted for a command
Which will run only in the top 3 panes
You can disable input on panes with select-pane -d
. To enable it again, do select-pane -e
I have a shortcut for this in my prefix:
bind -T marcos d select-pane -d
bind -T marcos e select-pane -e
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With