Kurt Peek
Kurt Peek

Reputation: 57451

How to enable shell command completion for gcloud?

I'm trying to install the Google Cloud SDK on a Mac (following https://cloud.google.com/sdk/docs/quickstart-mac-os-x), using the install.sh script:

~/Downloads$ ./google-cloud-sdk/install.sh

In the logged output, I see the following instructions:

==> Source [/Users/kurtpeek/Downloads/google-cloud-sdk/completion.bash.inc] in your profile to enable shell command completion for gcloud.
==> Source [/Users/kurtpeek/Downloads/google-cloud-sdk/path.bash.inc] in your profile to add the Google Cloud SDK command line tools to your $PATH.

Indeed, I find that using the gsutil command still leads to a -bash: gsutil: command not found error, so I still probably have to perform this step.

It is not entirely clear to me, however, what is meant by these instructions. I'm on a Mac and my bash profile is ~/.bash_profile. What lines would I have to add in order to make the command line completion work?

Update

The first time I installed I did not use sudo. Reinstalling with sudo, I get an additional prompt whether to modify my bash profile, which upon accepting leads to the following lines added to my .bash_profile:

# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/kurtpeek/Downloads/google-cloud-sdk/path.bash.inc' ]; then source '/Users/kurtpeek/Downloads/google-cloud-sdk/path.bash.inc'; fi

# The next line enables shell command completion for gcloud.
if [ -f '/Users/kurtpeek/Downloads/google-cloud-sdk/completion.bash.inc' ]; then source '/Users/kurtpeek/Downloads/google-cloud-sdk/completion.bash.inc'; fi

However, I still get gsutil: command not found errors.

Upvotes: 17

Views: 26955

Answers (2)

Tushar Phatangare
Tushar Phatangare

Reputation: 21

For Mac Run below command to run the install.sh :

sudo chmod +x install.sh

Upvotes: 2

Kurt Peek
Kurt Peek

Reputation: 57451

The trick was to run the install.sh using sudo as described in the update. After that I needed to restart the terminal (as described in the instructions) for the changes to take effect.

Upvotes: 14

Related Questions