Docker技术入门与实战 第二版-学习笔记-10-Docker Machine 项目-3-Command-line completion命令补全

时间:2023-03-08 19:41:19
Docker技术入门与实战 第二版-学习笔记-10-Docker Machine 项目-3-Command-line completion命令补全

Command-line completion

https://docs.docker.com/machine/completion/

Installing Command Completion——实现docker命令的自动补全

Docker for Mac comes with scripts to enable completion for the dockerdocker-machine, and docker-compose commands. The completion scripts may be found inside Docker.app, in the Contents/Resources/etc/ directory and can be installed both in Bash and Zsh.

Mac的Docker附带了一些脚本,用于支持dockerdocker-machinedocker-compose命令的完成。completion脚本可以在Docker.app中找到,在Contents/Resources/etc/目录,可以安装在Bash和Zsh

1)Bash

Bash has built-in support for completion To activate completion for Docker commands, these files need to be copied or symlinked to your bash_completion.d/directory. For example, if you installed bash via Homebrew:

Bash内置了对completion的支持,可以激活Docker命令的完成,需要复制这些文件或将这些文件链接到bash_completion.d/目录。例如,如果你通过Homebrew安装bash:

etc=/Applications/Docker.app/Contents/Resources/etc
ln -s $etc/docker.bash-completion $(brew --prefix)/etc/bash_completion.d/docker
ln -s $etc/docker-machine.bash-completion $(brew --prefix)/etc/bash_completion.d/docker-machine
ln -s $etc/docker-compose.bash-completion $(brew --prefix)/etc/bash_completion.d/docker-compose

用于自动补全命令

userdeMacBook-Pro:~ user$ brew install bash-completion
Updating Homebrew...
==> Auto-updated Homebrew!
Updated taps (homebrew/core, homebrew/cask and ethereum/ethereum).
==> New Formulae
anycable-go fx kubespy react-native-cli
aom gambit-scheme minica redis@4.0
astrometry-net ghr opa ruby@2.5
atomist-cli goreman pass-otp sng
curl-openssl i386-elf-gdb php@7.2 swagger-codegen@
dav1d interactive-rebase-tool pict tass64
dhall istioctl postgresql@ termtosvg
dnscontrol jmxterm qalculate-gtk up
easyengine kubeseal rargs websocat
==> Updated Formulae
ethereum ✔ golang-migrate packer
ethereum/ethereum/ethereum ✔ gopass paket
go ✔ goreleaser pandoc
icu4c ✔ gowsdl pandoc-citeproc
mongodb ✔ gphoto2 pandoc-crossref
node ✔ gpsbabel parallel
openssl ✔ gradio parallelstl
sqlite ✔ gradle passenger
wget ✔ grafana pazpar2
abcm2ps grails pcl
....
==> Renamed Formulae
gutenberg -> zola hh -> hstr mat -> mat2
==> Deleted Formulae
apple-gcc42 ffmbc gv pldebugger
aptly-completion gradle@2.14 php@7.0 ==> Downloading https://homebrew.bintray.com/bottles/bash-completion-1.3_3.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring bash-completion-.3_3.mojave.bottle.tar.gz
==> Caveats
Add the following line to your ~/.bash_profile:
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary