aws.plugin.zsh 603 B

12345678910111213141516171819202122232425262728
  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. source $(brew --prefix)/opt/awscli/libexec/bin/aws_zsh_completer.sh
  21. else
  22. source `which aws_zsh_completer.sh`
  23. fi