aws.plugin.zsh 732 B

12345678910111213141516171819202122232425262728293031
  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 RPROMPT="<aws:$AWS_DEFAULT_PROFILE>"
  14. }
  15. function aws_profiles {
  16. reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/'))
  17. }
  18. compctl -K aws_profiles asp
  19. if _homebrew-installed && _awscli-homebrew-installed ; then
  20. _aws_zsh_completer_path=$(brew --prefix awscli)/libexec/bin/aws_zsh_completer.sh
  21. else
  22. _aws_zsh_completer_path=$(which aws_zsh_completer.sh)
  23. fi
  24. [ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path
  25. unset _aws_zsh_completer_path