Created
July 12, 2022 00:43
-
-
Save 0xBEEFCAF3/06e37984420272f59c048695e0c9ff66 to your computer and use it in GitHub Desktop.
I take no credit. SSH tmux multiplexer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -exo pipefail | |
decs_insts=$(aws --region us-east-1 ec2 describe-instances) | |
ssh_list=($(echo $decs_insts | jq -r --arg match "${1}" '.Reservations[]|select(.Instances[]|select((.Tags[]|select(.Key=="Name")|.Value)|match($match)))|select(.Instances[]|select(.State|select(.Name=="running")))|.Instances[].PrivateIpAddress' | tr '\r\n' ' ')) | |
split_list=() | |
for ssh_entry in "${ssh_list[@]:1}"; do | |
split_list+=( split-pane ssh "$ssh_entry" ';' ) | |
done | |
tmux new-session ssh "${ssh_list[0]}" ';' \ | |
"${split_list[@]}" \ | |
select-layout tiled ';' \ | |
set-option -w synchronize-panes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment