Skip to content

Instantly share code, notes, and snippets.

@agargiulo
Forked from anonymous/boto.zsh
Last active December 18, 2015 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agargiulo/5807821 to your computer and use it in GitHub Desktop.
Save agargiulo/5807821 to your computer and use it in GitHub Desktop.
setopt extendedglob
typeset -a boto_web_envs
for cfg in `echo ~/.botocfg/(*~*.aws.cfg)`;do
boto_web_envs+="${cfg:t:r}"
done
benv(){
if [[ "$1" == "" ]];
then
print "Usage: $0 env-name\n" >&2
print "Valid benv's include:" >&2
print " ${(j:\n:)boto_web_envs}" >&2
return 1
elif [[ "${boto_web_envs[(r)$1]}" != "$1" ]]
then
print "Invalid benv." >&2
print "Valid benv's include:" >&2
print " ${(j:\n:)boto_web_envs}" >&2
return 2
else
export AWS_CREDENTIAL_FILE=~/.botocfg/$1.aws.cfg
export BOTO_PATH=/etc/boto.cfg:~/.boto:~/.botocfg/$1.cfg
fi
}
compctl -k boto_web_envs benv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment