From cb7b6b8f63588272d62f2c893cce841b5aa32680 Mon Sep 17 00:00:00 2001 From: Noah Masur Date: Sun, 19 Jul 2020 19:48:11 -0400 Subject: [PATCH] first attempt at cloud ssh --- zsh/functions | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/zsh/functions b/zsh/functions index 9c4782c..cae253f 100644 --- a/zsh/functions +++ b/zsh/functions @@ -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 +}