gcloud compute ssh
当我使用命令行完成时,如何停止为空格添加不必要的转义字符?例如,当我输入gcloud compute ssh
并点击时,<tab>
我得到的是:
greg@elfland ~> gcloud compute ssh
dbclone-gcp\ --zone=us-central1-a joints-io-vbxq\ --zone=us-central1-a joints-web-ffq1\ --zone=us-central1-f
joints-cron-538-2\ --zone=us-central1-a joints-io-vvkx\ --zone=us-central1-a joints-web-hk3c\ --zone=us-central1-b
joints-cron-tp1m\ --zone=us-central1-a joints-prod-haproxy\ --zone=us-central1-a joints-web-hqtf\ --zone=us-central1-b
joints-customer-vps\ --zone=us-central1-a joints-prod-mariadb1\ --zone=us-central1-a joints-web-jqfm\ --zone=us-central1-c
joints-io-0fsq\ --zone=us-central1-a joints-prod-mariadb2\ --zone=us-central1-a joints-web-pph5\ --zone=us-central1-f
joints-io-538-2\ --zone=us-central1-a joints-prod-rabbitmq-1\ --zone=us-central1-a joints-web-qvs5\ --zone=us-central1-a
joints-io-6dtn\ --zone=us-central1-a joints-prod-truenas\ --zone=us-central1-a
\
如果我尝试使用其中一个选项,由于空格字符的转义,它将不起作用:
greg@elfland ~> gcloud compute ssh joints-io-vvkx\ --zone=us-central1-a
Unable to find an instance with name [joints-io-vvkx --zone=us-central1-a].
For the following instance:
- [joints-io-vvkx --zone=us-central1-a]
choose a zone:
[1] asia-east1-a
[2] asia-east1-b
[3] asia-east1-c
[4] asia-east2-a
...
它要求输入区域,这很愚蠢,因为该命令试图用 标记区域--zone=
。当然,由于\
空格字符的转义,gcloud
将整个字符串视为主机名 ( [joints-io-vvkx --zone=us-central1-a]
)。如果我删除该\
字符,那么它会按预期工作:
greg@elfland ~> gcloud compute ssh joints-io-vvkx --zone=us-central1-a
External IP address was not found; defaulting to using IAP tunneling.
Warning: Permanently added 'compute.2162772965953140468' (ED25519) to the list of known hosts.
[greg@joints-io-vvkx ~]$
我的rc
文件有
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/greg/Applications/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/greg/Applications/google-cloud-sdk/path.zsh.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/greg/Applications/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/greg/Applications/google-cloud-sdk/completion.zsh.inc'; fi
如果这有帮助的话。此外,这是我的版本信息:
greg@elfland ~> gcloud --version
Google Cloud SDK 448.0.0
bq 2.0.98
core 2023.09.22
gcloud-crc32c 1.0.0
gke-gcloud-auth-plugin 0.5.6
gsutil 5.25