2019-09-20 19:58:35 +08:00
|
|
|
#####################################################
|
|
|
|
# gcloud plugin for oh-my-zsh #
|
|
|
|
# Author: Ian Chesal (github.com/ianchesal) #
|
|
|
|
#####################################################
|
|
|
|
|
|
|
|
if [[ -z "${CLOUDSDK_HOME}" ]]; then
|
|
|
|
search_locations=(
|
|
|
|
"$HOME/google-cloud-sdk"
|
2023-06-26 16:35:38 +08:00
|
|
|
"/usr/local/share/google-cloud-sdk"
|
2019-09-20 19:58:35 +08:00
|
|
|
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
2021-09-06 17:28:32 +08:00
|
|
|
"/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
2024-03-30 15:26:14 +08:00
|
|
|
"/opt/homebrew/share/google-cloud-sdk"
|
2019-09-20 19:58:35 +08:00
|
|
|
"/usr/share/google-cloud-sdk"
|
|
|
|
"/snap/google-cloud-sdk/current"
|
2023-02-17 15:09:00 +08:00
|
|
|
"/snap/google-cloud-cli/current"
|
2022-04-26 18:37:42 +08:00
|
|
|
"/usr/lib/google-cloud-sdk"
|
|
|
|
"/usr/lib64/google-cloud-sdk"
|
2019-09-22 05:11:25 +08:00
|
|
|
"/opt/google-cloud-sdk"
|
2023-06-01 05:59:41 +08:00
|
|
|
"/opt/google-cloud-cli"
|
2022-08-26 10:02:35 +08:00
|
|
|
"/opt/local/libexec/google-cloud-sdk"
|
2024-01-05 17:38:26 +08:00
|
|
|
"$HOME/.asdf/installs/gcloud/*/"
|
2019-09-20 19:58:35 +08: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 18:37:42 +08:00
|
|
|
unset search_locations gcloud_sdk_location
|
2019-09-20 19:58:35 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if (( ${+CLOUDSDK_HOME} )); then
|
2023-09-20 18:09:46 +08:00
|
|
|
# Source path file
|
|
|
|
if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
|
|
|
|
source "${CLOUDSDK_HOME}/path.zsh.inc"
|
2019-09-20 19:58:35 +08:00
|
|
|
fi
|
2022-04-26 18:37:42 +08: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 19:58:35 +08:00
|
|
|
export CLOUDSDK_HOME
|
|
|
|
fi
|