I could get around similar problem this way:
#!/bin/bash
tmp=$(mktemp --tmpdir=/tmp/).tmux
cleanup () {
rm -f "$tmp"
}
trap cleanup EXIT
dump_cmd () {
local i=$1
shift
echo "tcpdump -i $i -s 1500 \"port 67 or port 68\" -e $@"
}
cat <<-EOT > "$tmp"
new-window
send-keys '$(dump_cmd eno1)' Enter
splitw -v -p 50
send-keys '$(dump_cmd enp12s0f2)' Enter
EOT
tmux new 'tmux move-window -t 99 \; source-file '"$tmp"
# EOF #
This script starts two sniffers on two interfaces in two panes.
P.S.
One may use simply
new-window '$(dump_cmd eno1)'
splitw -v -p 50 '$(dump_cmd enp12s0f2)'
instead of those four lines, but ^C
to tcpdump
will kill that pane too.
This may not be what you want.