gcloud.plugin.zsh 969 B

1234567891011121314151617181920212223242526272829303132
  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. )
  13. for gcloud_sdk_location in $search_locations; do
  14. if [[ -d "${gcloud_sdk_location}" ]]; then
  15. CLOUDSDK_HOME="${gcloud_sdk_location}"
  16. break
  17. fi
  18. done
  19. fi
  20. if (( ${+CLOUDSDK_HOME} )); then
  21. if (( ! $+commands[gcloud] )); then
  22. # Only source this if GCloud isn't already on the path
  23. if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
  24. source "${CLOUDSDK_HOME}/path.zsh.inc"
  25. fi
  26. fi
  27. source "${CLOUDSDK_HOME}/completion.zsh.inc"
  28. export CLOUDSDK_HOME
  29. fi