Command-line completion
https://docs.docker.com/machine/completion/
Installing Command Completion——實現docker命令的自動補全
Docker for Mac comes with scripts to enable completion for the docker
, docker-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.php
Mac的Docker附帶了一些腳本,用於支持docker
、docker-machine
和docker-compose
命令的完成。completion腳本能夠在Docker.app
中找到,在Contents/Resources/etc/
目錄,能夠安裝在Bash和Zshhtml
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:node
Bash內置了對completion的支持,能夠激活Docker命令的完成,須要複製這些文件或將這些文件連接到bash_completion.d/目錄。例如,若是你經過Homebrew安裝bash:react
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
用於自動補全命令git
userdeMacBook-Pro:~ user$ brew install bash-completion Updating Homebrew... ==> Auto-updated Homebrew! Updated 3 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@2 dav1d interactive-rebase-tool pict tass64 dhall istioctl postgresql@10 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-1.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 🍺 /usr/local/Cellar/bash-completion/1.3_3: 189 files, 607.8KB userdeMacBook-Pro:~ user$ sudo curl -L https://raw.githubusercontent.com/docker/machine/v0.16.0/contrib/completion/bash/docker-machine.bash -o `brew --prefix`/etc/bash_completion.d/docker-machine Password: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 12211 100 12211 0 0 6195 0 0:00:01 0:00:01 --:--:-- 6195
2)Zsh
In Zsh, the completion system takes care of things. To activate completion for Docker commands, these files need to be copied or symlinked to your Zsh site-functions/
directory. For example, if you installed Zsh via Homebrew:github
在Zsh中,completion系統負責處理事情。要激活Docker命令的完成,須要將這些文件複製或符號連接到Zsh的site-functions/
目錄。例如,若是你經過Homebrew安裝Zsh:golang
etc=/Applications/Docker.app/Contents/Resources/etc ln -s $etc/docker.zsh-completion /usr/local/share/zsh/site-functions/_docker ln -s $etc/docker-machine.zsh-completion /usr/local/share/zsh/site-functions/_docker-machine ln -s $etc/docker-compose.zsh-completion /usr/local/share/zsh/site-functions/_docker-compose