-
Notifications
You must be signed in to change notification settings - Fork 0
/
muxSend
executable file
·36 lines (31 loc) · 888 Bytes
/
muxSend
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# vim: set ft=sh
if [[ $# < 2 ]];then
exit
fi
var=$1
shift
data="$@"
#echo "Current session or all (c|a)"
#read -n 1 var
#echo
if [[ $var =~ ^a.* ]];then
for sess in `tmux list-sessions | cut -d ":" -f 1`;do
tmux set-buffer -t $sess "$data"
for window in `tmux list-windows -t $sess | tr -d ' '`;do
if grep -q -E "(zsh|bash)" <<< $window;then
tmux paste-buffer -t $sess:${window%:*}
#tmux send-keys -t $sess:$window "C-c"
tmux send-keys -t $sess:${window%:*} "Enter"
fi
done
done
else
tmux set-buffer "$data"
for window in `tmux list-windows | tr -d ' '`;do
if grep -q -E "(zsh|bash)" <<< $window;then
tmux paste-buffer -t ${window%:*}
tmux send-keys -t ${window%:*} "Enter"
fi
done
fi