diff options
author | Ben Burwell <ben@benburwell.com> | 2019-08-13 23:33:32 -0400 |
---|---|---|
committer | Ben Burwell <ben@benburwell.com> | 2019-08-13 23:33:32 -0400 |
commit | 8e4d61fb77ed68f896b6fe3dc0bbbcd078668ede (patch) | |
tree | d521e523316d239caea0bf4a35ce851236dad53e /templates/.zsh/functions/sheb.zsh | |
parent | 7d4c541a0d4f09eb421425f8d49b65308d9e6cfd (diff) |
zsh: adopt
Diffstat (limited to 'templates/.zsh/functions/sheb.zsh')
-rw-r--r-- | templates/.zsh/functions/sheb.zsh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/templates/.zsh/functions/sheb.zsh b/templates/.zsh/functions/sheb.zsh new file mode 100644 index 0000000..64efe66 --- /dev/null +++ b/templates/.zsh/functions/sheb.zsh @@ -0,0 +1,22 @@ +function sheb() { + # if an address wasn't specified, use the ec2 command to select an instance + if [[ $# == "0" ]]; then + 1=$(ec2 | fzf --no-multi --prompt="ec2 instance> " | sed 's/ .*//') + if [[ -z "$1" ]]; then + return 1 + fi + fi + + # first add key to agent if necessary + if [[ ! $(ssh-add -L) ]]; then + ssh-add -K ~/.ssh/id_rsa + fi + + if [[ $(echo "$1" | grep "@") ]]; then + # If a username was provided, use it + ssh -J virtyx -t "$1" "sudo su -" + else + # Otherwise, assume username is "ec2-user" + ssh -J virtyx -t "ec2-user@$1" "sudo su -" + fi +} |