Docker ZSH autocomplete and denter on MacOS

By | 2019年07月25日

可参考 https://docs.docker.com/docker-for-mac/install/

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

添加自定义函数到~/.zshrc

function denter(){
 if [ -z "$1" ]; then echo "\nPlease:\n denter [ContainerName]\n\nView:\n docker container ls\n" ;else docker exec -it "$1" /bin/bash ;fi;
}

可通过denter [Container Name] 进入docker机器

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据