<p>Cannot get <code>kubectl</code> bash completion to work on Mac. I installed <code>bash-completion</code> with <code>brew</code> i.e. <code>brew install bash-completion</code> then as per the install notes, added it to the <code>~/.bash_profile</code>:</p>

<p><code>if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi
</code></p>

<p>But still getting the error <code>kubectl -bash: _init_completion: command not found</code> after re-sourcing the profile.</p>

<p>A patch was provided to fix the issue with bash completion for kubectl. You'll need to use the patch for now if you are on osx until the PR is merged and source the bash completion again, you will also need to install <code>bash-completion</code> as described in the question above.</p>

<p><a href="https://github.com/kubernetes/kubernetes/issues/12400#issuecomment-137567835" rel="nofollow">kubectl patch</a></p>

<p><a href="https://github.com/kubernetes/kubernetes/pull/13570" rel="nofollow">kubernetes pull request</a></p>

<p><strong>Edit:</strong> this was now merged into <a href="https://github.com/kubernetes/kubernetes/blob/master/contrib/completions/bash/kubectl" rel="nofollow">master</a></p>
