gcloud.plugin.zsh 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  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. "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
  10. "/usr/share/google-cloud-sdk"
  11. "/snap/google-cloud-sdk/current"
  12. "/usr/lib64/google-cloud-sdk/"
  13. "/opt/google-cloud-sdk"
  14. )
  15. for gcloud_sdk_location in $search_locations; do
  16. if [[ -d "${gcloud_sdk_location}" ]]; then
  17. CLOUDSDK_HOME="${gcloud_sdk_location}"
  18. break
  19. fi
  20. done
  21. fi
  22. if (( ${+CLOUDSDK_HOME} )); then
  23. if (( ! $+commands[gcloud] )); then
  24. # Only source this if GCloud isn't already on the path
  25. if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
  26. source "${CLOUDSDK_HOME}/path.zsh.inc"
  27. fi
  28. fi
  29. source "${CLOUDSDK_HOME}/completion.zsh.inc"
  30. export CLOUDSDK_HOME
  31. fi