2019-09-20 11:58:35 +00:00
|
|
|
#####################################################
|
|
|
|
# gcloud plugin for oh-my-zsh #
|
|
|
|
# Author: Ian Chesal (github.com/ianchesal) #
|
|
|
|
#####################################################
|
|
|
|
|
|
|
|
if [[ -z "${CLOUDSDK_HOME}" ]]; then
|
|
|
|
search_locations=(
|
|
|
|
"$HOME/google-cloud-sdk"
|
|
|
|
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
2021-09-06 09:28:32 +00:00
|
|
|
"/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
2019-09-20 11:58:35 +00:00
|
|
|
"/usr/share/google-cloud-sdk"
|
|
|
|
"/snap/google-cloud-sdk/current"
|
2023-02-17 07:09:00 +00:00
|
|
|
"/snap/google-cloud-cli/current"
|
2022-04-26 10:37:42 +00:00
|
|
|
"/usr/lib/google-cloud-sdk"
|
|
|
|
"/usr/lib64/google-cloud-sdk"
|
2019-09-21 21:11:25 +00:00
|
|
|
"/opt/google-cloud-sdk"
|
2023-05-31 21:59:41 +00:00
|
|
|
"/opt/google-cloud-cli"
|
2022-08-26 02:02:35 +00:00
|
|
|
"/opt/local/libexec/google-cloud-sdk"
|
2019-09-20 11:58:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
for gcloud_sdk_location in $search_locations; do
|
|
|
|
if [[ -d "${gcloud_sdk_location}" ]]; then
|
|
|
|
CLOUDSDK_HOME="${gcloud_sdk_location}"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2022-04-26 10:37:42 +00:00
|
|
|
unset search_locations gcloud_sdk_location
|
2019-09-20 11:58:35 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if (( ${+CLOUDSDK_HOME} )); then
|
2022-04-26 10:37:42 +00:00
|
|
|
# Only source this if gcloud isn't already on the path
|
2019-09-20 11:58:35 +00:00
|
|
|
if (( ! $+commands[gcloud] )); then
|
|
|
|
if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
|
|
|
|
source "${CLOUDSDK_HOME}/path.zsh.inc"
|
|
|
|
fi
|
|
|
|
fi
|
2022-04-26 10:37:42 +00:00
|
|
|
|
|
|
|
# Look for completion file in different paths
|
|
|
|
for comp_file (
|
|
|
|
"${CLOUDSDK_HOME}/completion.zsh.inc" # default location
|
|
|
|
"/usr/share/google-cloud-sdk/completion.zsh.inc" # apt-based location
|
|
|
|
); do
|
|
|
|
if [[ -f "${comp_file}" ]]; then
|
|
|
|
source "${comp_file}"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
unset comp_file
|
|
|
|
|
2019-09-20 11:58:35 +00:00
|
|
|
export CLOUDSDK_HOME
|
|
|
|
fi
|