first attempt at cloud ssh

This commit is contained in:
Noah Masur 2020-07-19 19:48:11 -04:00
parent 22d5131bca
commit cb7b6b8f63

View File

@ -107,3 +107,25 @@ unsetaws() {
copy() {
cat $1 | pbcopy
}
cloud() {
profile=${$1:-default}
search=${2:-prod}
num=${$3:-1}
ips=$(drips --raw | grep $search)
if [[ -z $ips ]]
then
echo "Failed to find instances."
return 1
fi
count=$(echo $ips | wc -l)
echo "Found ${count##*( )} instances."
ip=$(echo $ips | sed -n "$num"p | awk -F' - ' '{print $2}')
if [[ -z $ip ]]
then
echo "Not an available selection."
return 1
fi
update-ssh-config --host $search --hostname $ip
ssh $search
}