Skip to content

Instantly share code, notes, and snippets.

@Alives
Last active October 7, 2016 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alives/7fa3efcfdf156e9ca0e74b716c02aa3f to your computer and use it in GitHub Desktop.
Save Alives/7fa3efcfdf156e9ca0e74b716c02aa3f to your computer and use it in GitHub Desktop.
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