Skip to content

Instantly share code, notes, and snippets.

@Alives Alives/multi
Last active Oct 7, 2016

Embed
What would you like to do?
function multi {
cmd=$1
shift
while [[ $cmd = "ssh" ]]; do
pre_check="$(echo $@ | tr ' ' '\n' | sed -e 's/^.*@//g' | \
xargs nmap -p 22 -PN -oG - | grep Port | grep -v open)"
test "${pre_check}x" != "x" && (clear; echo "$pre_check") || break
done
tmux send-keys -t 0 "$cmd ${@[1]}"
for ((pane = 1; pane < ${#@[@]}; pane++)); do
tmux splitw -h
tmux send-keys -t $pane "$cmd ${@[pane+1]}"
tmux select-layout tiled > /dev/null
done
tmux set-window-option synchronize-panes on > /dev/null
tmux send-keys Enter
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.