如何为gcloud启用Shell命令完成功能? [英] How to enable shell command completion for gcloud?
问题描述
我正在尝试在Mac上安装Google Cloud SDK(遵循 https://cloud.google.com/sdk/docs/quickstart-mac-os-x ),使用install.sh
脚本:
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.
实际上,我发现使用gsutil
命令仍然会导致-bash: gsutil: command not found
错误,因此我仍然可能必须执行此步骤.
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.
对我来说,这还不是很清楚,但是这些说明的含义是什么.我在Mac上,我的bash个人资料为~/.bash_profile
.为了使命令行完成工作正常运行,我必须添加哪些行?
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?
更新
我第一次安装时没有使用sudo
.用sudo
重新安装时,我得到一个额外的提示,即是否要修改我的bash配置文件,该配置文件在接受后会导致将以下行添加到我的.bash_profile
:
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
但是,我仍然出现gsutil: command not found
错误.
However, I still get gsutil: command not found
errors.
推荐答案
技巧是按照更新中的描述使用sudo
运行install.sh
.之后,我需要重新启动终端(如说明中所述),以使更改生效.
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.
这篇关于如何为gcloud启用Shell命令完成功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!