Skip to content

Instantly share code, notes, and snippets.

@SteveByerly
Created March 14, 2017 20:15
Show Gist options
  • Save SteveByerly/9e8a6e313e7e996228fbe0faad65e2b1 to your computer and use it in GitHub Desktop.
Save SteveByerly/9e8a6e313e7e996228fbe0faad65e2b1 to your computer and use it in GitHub Desktop.
Custom version of aws ZSH plugin
_homebrew-installed() {
type brew &> /dev/null
}
_awscli-homebrew-installed() {
brew list awscli &> /dev/null
}
export AWS_HOME=~/.aws
function agp {
echo $AWS_DEFAULT_PROFILE
}
function asp {
local rprompt=${RPROMPT/<aws:$(agp)>/}
export AWS_DEFAULT_PROFILE=$1
export AWS_PROFILE=$1
export RPROMPT="<aws:$AWS_DEFAULT_PROFILE>$rprompt"
}
function aws_profiles {
reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/'))
}
compctl -K aws_profiles asp
# This is the default install location for homebrew. brew and
# brew list are very slow, so we'll check the default path first
if [ -f "/usr/local/bin/aws_zsh_completer.sh" ]; then
_aws_zsh_completer_path="/usr/local/bin/aws_zsh_completer.sh"
elif _homebrew-installed && _awscli-homebrew-installed ; then
_aws_zsh_completer_path=$(brew --prefix awscli)/libexec/bin/aws_zsh_completer.sh
else
_aws_zsh_completer_path=$(which aws_zsh_completer.sh)
fi
[ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path
unset _aws_zsh_completer_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment