Skip to content

Instantly share code, notes, and snippets.

@0xBEEFCAF3
Created July 12, 2022 00:43
Show Gist options
  • Save 0xBEEFCAF3/06e37984420272f59c048695e0c9ff66 to your computer and use it in GitHub Desktop.
Save 0xBEEFCAF3/06e37984420272f59c048695e0c9ff66 to your computer and use it in GitHub Desktop.
I take no credit. SSH tmux multiplexer
#!/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