官术网_书友最值得收藏!

Installing Docker command-line completion

Install Homebrew. You may (probably) already have Homebrew installed on your Mac, but if not, you should install it now. Here is the command to install it:

# install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Next, use Homebrew to install bash-completion. Here is the command:

# use homebrew to install bash completion 
brew install bash-completion

The installation of bash-completion will instruct you to add the following line to your ~/.bash_profile file:

# update the bash profile to enable bash completion for every terminal session 
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion

Now, create the links necessary to enable the Docker command-line completion feature. There is one link for each of the Docker toolsets. Here are the link commands for bash (if you use zsh, check the next code block for the link commands):

# create links for bash shell
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion $(brew --prefix)/etc/bash_completion.d/docker
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.bash-completion $(brew --prefix)/etc/bash_completion.d/docker-machine
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion $(brew --prefix)/etc/bash_completion.d/docker-compose

Note that if you are using zsh instead of bash, the link commands are different. Here are the link commands for zsh:

# create links for zsh shell
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.zsh-completion /usr/local/share/zsh/site-functions/_docker
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.zsh-completion /usr/local/share/zsh/site-functions/_docker-machine
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.zsh-completion /usr/local/share/zsh/site-functions/_docker-compose

Finally, restart your terminal session—you can now use Docker command completion! Try it by typing docker and hitting the Tab key twice.

主站蜘蛛池模板: 聂拉木县| 舞钢市| 岳池县| 襄樊市| 龙里县| 丁青县| 财经| 女性| 南昌市| 遂平县| 攀枝花市| 德格县| 徐闻县| 怀宁县| 青田县| 凌源市| 邢台市| 莎车县| 郯城县| 灯塔市| 绥德县| 罗田县| 高雄县| 丹棱县| 扎赉特旗| 沅江市| 永宁县| 平阳县| 邛崃市| 梨树县| 西林县| 涞水县| 新泰市| 视频| 锡林郭勒盟| 宣威市| 泰兴市| 青神县| 邻水| 辰溪县| 城口县|