aws.plugin.zsh 809 B

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