Make sure you have installed oh-my-zsh
on your computer.
WITH OH-MY-ZSH SHELL
Add docker
and docker-compose
to the plugins list in ~/.zshrc
to run autocompletion within the oh-my-zsh shell. In the following example, ...
represent other Zsh plugins you may have installed.
plugins=( ... docker docker-compose )
WITHOUT OH-MY-ZSH SHELL
Place the completion script in your
/path/to/zsh/completion
(typically ~/.zsh/completion/
):
mkdir -p ~/.zsh/completion curl -L https://raw.githubusercontent.com/docker/compose/1.25.0/contrib/completion/zsh/_docker-compose > ~/.zsh/completion/_docker-compose curl -L https://raw.githubusercontent.com/docker/docker/master/contrib/completion/zsh/_docker > ~/.zsh/completion/_docker
Include the directory in your $fpath
by adding in ~/.zshrc
:
fpath=(~/.zsh/completion $fpath)
Make sure compinit
is loaded or do it by adding in ~/.zshrc
:
autoload -Uz compinit && compinit -i
Then reload your shell:
exec $SHELL -l
Issues
I add docker
in .zshrc
. plugins=(git docker)
and restart my Terminal, but [TAB][TAB] is not working.
[为隐藏内容,请登录(login)以显示!]
参考资料:
https://docs.docker.com/compose/completion/
https://github.com/ohmyzsh/ohmyzsh/issues/7642