From 6ccb6c8eef3c74fe2fb058f010de8ae3fb58e388 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Sun, 10 Jan 2021 19:23:11 +0530 Subject: [PATCH] formatted gcloud completion and used helper function --- completion/available/gcloud.completion.bash | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/completion/available/gcloud.completion.bash b/completion/available/gcloud.completion.bash index 908ee9c5..5a4899b9 100644 --- a/completion/available/gcloud.completion.bash +++ b/completion/available/gcloud.completion.bash @@ -1,9 +1,13 @@ #/usr/bin/env bash # Bash completion for Google Cloud SDK -if which gcloud >/dev/null 2>&1; then - GOOGLE_SDK_ROOT=${GOOGLE_SDK_ROOT:-$(gcloud info --format="value(installation.sdk_root)")} - for i in $(ls ${GOOGLE_SDK_ROOT}/*.bash.inc); do - source $i - done +if _command_exists gcloud +then + # get install path + GOOGLE_SDK_ROOT=${GOOGLE_SDK_ROOT:-$(gcloud info --format="value(installation.sdk_root)")} + + # souce all the bash completion file that are available + for i in $(ls ${GOOGLE_SDK_ROOT}/*.bash.inc); do + source $i + done fi