bash completion for Docker and kubernetes !

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:

You can reload it using:

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 :

Bash completion for docker, docker-machine and docker-compose

Run those 3 commands :

and add the following to the end of your ~/.bash_profile (or ~/.bash_rc if running Linux) :

Now source (if running Linux, source ~/.bash_rc)

And enjoy tab’ing :

References :

 

2 réflexions sur « bash completion for Docker and kubernetes ! »

  1. 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

  2. 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.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *