18d2152798e15898f3c11a2fd3d8a59a62b4ac33

Author
James Yeoman <JamesYeoman@users.noreply.github.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

feat(gcloud): support for official apt repo (#10889)

Fixes #10888
Closes #10889

Diff

 1diff --git a/plugins/gcloud/gcloud.plugin.zsh b/plugins/gcloud/gcloud.plugin.zsh
 2index 7368eb3a6f56bcef59107cef7f76b7f17dc9f863..d43c62178072711908be1485e4363c83d80e0947 100644
 3--- a/plugins/gcloud/gcloud.plugin.zsh
 4+++ b/plugins/gcloud/gcloud.plugin.zsh
 5@@ -10,7 +10,8 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then
 6     "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
 7     "/usr/share/google-cloud-sdk"
 8     "/snap/google-cloud-sdk/current"
 9-    "/usr/lib64/google-cloud-sdk/"
10+    "/usr/lib/google-cloud-sdk"
11+    "/usr/lib64/google-cloud-sdk"
12     "/opt/google-cloud-sdk"
13   )
14 
15@@ -20,15 +21,28 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then
16       break
17     fi
18   done
19+  unset search_locations gcloud_sdk_location
20 fi
21 
22 if (( ${+CLOUDSDK_HOME} )); then
23+  # Only source this if gcloud isn't already on the path
24   if (( ! $+commands[gcloud] )); then
25-    # Only source this if GCloud isn't already on the path
26     if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
27       source "${CLOUDSDK_HOME}/path.zsh.inc"
28     fi
29   fi
30-  source "${CLOUDSDK_HOME}/completion.zsh.inc"
31+
32+  # Look for completion file in different paths
33+  for comp_file (
34+    "${CLOUDSDK_HOME}/completion.zsh.inc"             # default location
35+    "/usr/share/google-cloud-sdk/completion.zsh.inc"  # apt-based location
36+  ); do
37+    if [[ -f "${comp_file}" ]]; then
38+      source "${comp_file}"
39+      break
40+    fi
41+  done
42+  unset comp_file
43+
44   export CLOUDSDK_HOME
45 fi