| 
									
										
										
										
											2019-09-20 04:58:35 -07: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 11:28:32 +02:00
										 |  |  |     "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" | 
					
						
							| 
									
										
										
										
											2019-09-20 04:58:35 -07:00
										 |  |  |     "/usr/share/google-cloud-sdk" | 
					
						
							|  |  |  |     "/snap/google-cloud-sdk/current" | 
					
						
							| 
									
										
										
										
											2022-04-26 11:37:42 +01:00
										 |  |  |     "/usr/lib/google-cloud-sdk" | 
					
						
							|  |  |  |     "/usr/lib64/google-cloud-sdk" | 
					
						
							| 
									
										
										
										
											2019-09-21 18:11:25 -03:00
										 |  |  |     "/opt/google-cloud-sdk" | 
					
						
							| 
									
										
										
										
											2022-08-25 22:02:35 -04:00
										 |  |  |     "/opt/local/libexec/google-cloud-sdk" | 
					
						
							| 
									
										
										
										
											2019-09-20 04:58:35 -07: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 11:37:42 +01:00
										 |  |  |   unset search_locations gcloud_sdk_location | 
					
						
							| 
									
										
										
										
											2019-09-20 04:58:35 -07:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (( ${+CLOUDSDK_HOME} )); then | 
					
						
							| 
									
										
										
										
											2022-04-26 11:37:42 +01:00
										 |  |  |   # Only source this if gcloud isn't already on the path | 
					
						
							| 
									
										
										
										
											2019-09-20 04:58:35 -07:00
										 |  |  |   if (( ! $+commands[gcloud] )); then | 
					
						
							|  |  |  |     if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then | 
					
						
							|  |  |  |       source "${CLOUDSDK_HOME}/path.zsh.inc" | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |   fi | 
					
						
							| 
									
										
										
										
											2022-04-26 11:37:42 +01: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 04:58:35 -07:00
										 |  |  |   export CLOUDSDK_HOME | 
					
						
							|  |  |  | fi |