gcloud.plugin.zsh 997 B

123456789101112131415161718192021222324252627282930313233
  1. #####################################################
  2. # gcloud plugin for oh-my-zsh #
  3. # Author: Ian Chesal (github.com/ianchesal) #
  4. #####################################################
  5. if [[ -z "${CLOUDSDK_HOME}" ]]; then
  6. search_locations=(
  7. "$HOME/google-cloud-sdk"
  8. "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
  9. "/usr/share/google-cloud-sdk"
  10. "/snap/google-cloud-sdk/current"
  11. "/usr/lib64/google-cloud-sdk/"
  12. "/opt/google-cloud-sdk"
  13. )
  14. for gcloud_sdk_location in $search_locations; do
  15. if [[ -d "${gcloud_sdk_location}" ]]; then
  16. CLOUDSDK_HOME="${gcloud_sdk_location}"
  17. break
  18. fi
  19. done
  20. fi
  21. if (( ${+CLOUDSDK_HOME} )); then
  22. if (( ! $+commands[gcloud] )); then
  23. # Only source this if GCloud isn't already on the path
  24. if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
  25. source "${CLOUDSDK_HOME}/path.zsh.inc"
  26. fi
  27. fi
  28. source "${CLOUDSDK_HOME}/completion.zsh.inc"
  29. export CLOUDSDK_HOME
  30. fi