aws.plugin.zsh 764 B

1234567891011121314151617181920212223242526272829303132
  1. _homebrew-installed() {
  2. type brew &> /dev/null
  3. }
  4. _awscli-homebrew-installed() {
  5. brew list awscli &> /dev/null
  6. }
  7. export AWS_HOME=~/.aws
  8. function agp {
  9. echo $AWS_DEFAULT_PROFILE
  10. }
  11. function asp {
  12. export AWS_DEFAULT_PROFILE=$1
  13. export AWS_PROFILE=$1
  14. export RPROMPT="<aws:$AWS_DEFAULT_PROFILE>$RPROMPT"
  15. }
  16. function aws_profiles {
  17. reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/'))
  18. }
  19. compctl -K aws_profiles asp
  20. if _homebrew-installed && _awscli-homebrew-installed ; then
  21. _aws_zsh_completer_path=$(brew --prefix awscli)/libexec/bin/aws_zsh_completer.sh
  22. else
  23. _aws_zsh_completer_path=$(which aws_zsh_completer.sh)
  24. fi
  25. [ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path
  26. unset _aws_zsh_completer_path