如何为gcloud启用shell命令完成?

Kur*_*eek 8 bash shell google-cloud-platform

我正在尝试使用以下脚本在Mac上安装Google Cloud SDK(关注https://cloud.google.com/sdk/docs/quickstart-mac-os-x)install.sh:

~/Downloads$ ./google-cloud-sdk/install.sh
Run Code Online (Sandbox Code Playgroud)

在记录的输出中,我看到以下说明:

==> 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.
Run Code Online (Sandbox Code Playgroud)

实际上,我发现使用该gsutil命令仍然会导致-bash: gsutil: command not found错误,所以我仍然可能必须执行此步骤.

然而,我并不完全清楚这些指示的含义.我在Mac上,我的bash配置文件是~/.bash_profile.为了使命令行完成工作,我必须添加哪些行?

更新

我第一次安装时没用过sudo.重新安装sudo,我得到一个额外的提示是否修改我的bash配置文件,接受后导致以下行添加到我的.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
Run Code Online (Sandbox Code Playgroud)

但是,我仍然会遇到gsutil: command not found错误.

Kur*_*eek 11

诀窍是按照更新中的描述运行install.sh使用sudo.之后,我需要重新启动终端(如说明中所述)才能使更改生效.