【问题标题】:How to enable shell command completion for gcloud?如何为 gcloud 启用 shell 命令完成?
【发布时间】:2019-07-11 18:57:15
【问题描述】:

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

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

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

==> 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 错误,所以我仍然可能必须执行这一步。

但是,我并不完全清楚这些说明的含义。我在 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

但是,我仍然收到 gsutil: command not found 错误。

【问题讨论】:

  • 你能告诉我们which gsutil的输出吗?
  • which gsutil 没有输出...
  • 对于 Ubuntu (20.04 LTS),我找到了一个 few commands 解决了我的问题!

标签: bash shell google-cloud-platform


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    对于 Mac 运行以下命令以运行 install.sh

    sudo chmod +x install.sh

    【讨论】:

      猜你喜欢
      • 2021-05-27
      • 2011-08-06
      • 2021-12-11
      • 1970-01-01
      • 1970-01-01
      • 2015-01-14
      • 2017-02-13
      • 2013-04-03
      • 1970-01-01
      相关资源
      最近更新 更多