Contents
(oh my) zsh update, october 2019
Using oh my zsh ? Well then, things got even simpler, thanks to the integrated plugins!
Just make sure to have this in your ~/.zshrc file:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
plugins=( git bundler dotenv osx docker docker-compose minikube kubectl brew node npm ) |
You can reload it using:
1 |
source ~/.zshrc |
And make sure to not add any comments, coma (« , ») or anything else into this list; just indent each line properly.
Updated on June 20th 2019 with Helm, Kubernetes and Minikube !
When you interact a lot with command line tools, such as : docker , docker-machine and docker-compose, command line completion (using the tab key) is a must.
Let’s have a look at how to enable bash completion for those docker command line tools
Mac user ? install bash-completion
I suppose you already use brew on Mac to install additional packages; it’s time to install bash-completion :
1 |
$ brew install bash-completion |
Bash completion for docker, docker-machine and docker-compose
Run those 3 commands :
1 |
$ curl https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /usr/local/etc/bash_completion.d/docker |
1 |
$ curl -L https://raw.githubusercontent.com/docker/compose/1.24.0/contrib/completion/bash/docker-compose -o /usr/local/etc/bash_completion.d/docker-compose |
1 |
$ curl -L https://raw.githubusercontent.com/docker/machine/v0.16.0/contrib/completion/bash/docker-machine.bash -o /usr/local/etc/bash_completion.d/docker-machine |
1 |
$ minikube completion bash > /usr/local/etc/bash_completion.d/minikube-completion |
and add the following to the end of your ~/.bash_profile (or ~/.bash_rc if running Linux) :
1 2 3 4 5 |
if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi source <(kubectl completion bash) source <(helm completion bash) |
Now source (if running Linux, source ~/.bash_rc)
1 |
$ source ~/.bash_profile |
And enjoy tab’ing :
1 2 3 |
$ docker attach commit create diff exec help images info kill login logs pause ps push restart rmi save start stop top version wait build cp daemon events export history import inspect load logout network port pull rename rm run search stats tag unpause volume |
1 2 3 |
$ docker-compose build kill migrate-to-labels port pull rm scale stop up help logs pause ps restart run start unpause version |
1 2 3 |
$ docker-machine active create help ip ls restart scp start stop url config env inspect kill regenerate-certs rm ssh status upgrade |
References :
- docker-compose completion article on docker.com
- docker-machine completion scripts on github
- docker completion scripts on github
I ran into the following issue when tabbing for anything that includes colon :
-bash: __ltrim_colon_completions: command not found
Need to add the following in the ~/.bash_profile
if [ -f $(brew –prefix)/etc/bash_completion ]; then
. $(brew –prefix)/etc/bash_completion
fi
I’ve just installed these autocompletions with latests versions and it works great.
During bash-completion installation it shows a message noticing that you’ve to put that if .. fi commented previously on your bash_profile, it seems to be their standard way.