Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send command to all window in tmux

Is a way to send the same command to all window in tmux, not to all pane in window. synchronize-panes - send command to all pane in one window. I need something like 'at' in screen.

like image 551
vorand Avatar asked Sep 05 '25 03:09

vorand


2 Answers

You could always do something like this:

session=mysession
message="hello world"
tmux list-windows -t $session|cut -d: -f1|xargs -I{} tmux send-keys -t $session:{} $message

You could also bind this to a key in your tmux.conf like this:

bind C-e command-prompt -p "session?,message?" "run-shell \"tmux list-windows -t %1 \| cut -d: -f1\|xargs -I\{\} tmux send-keys -t %1:\{\} %2\""
like image 135
Alex Gaudio Avatar answered Sep 07 '25 23:09

Alex Gaudio


You could do something like this: https://gist.github.com/2773454

But this executes for every pane, but you could adjust accordingly.

All depends what your trying to accomplish, for this an example of what i want to accomplish is to source ~/.zsh in all panes.

like image 30
DebugXYZ Avatar answered Sep 08 '25 00:09

DebugXYZ