I'm using kubectl from within a docker container running on a Mac. I've already successfully configured the bash completion for kubectl to work on the Mac, however, it doesn't work within the docker container. I always get bash: _get_comp_words_by_ref: command not found
.
The docker image is based on ubuntu:16.04
and kubectl is installed via the line (snippet from the dockerfile)
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
mv kubectl /usr/local/bin
echo $BASH_VERSION
gives me 4.3.48(1)-release
, and according to apt, the bash-completion
package is installed.
I'm using iTerm2 as terminal.
Any idea why it doesn't work or how to get it to work?
To use shell autocompletion with kubectl simply press tab while writing out a command. For example we can type g and then press tab to autocomplete to get . When we type s you may expect pressing tab would autocomplete to service, but in this case there are more than a few options for words starting with s .
If the autocomplete results contain directories only (no files), then Bash Completion is installed. If the autocomplete results include files, then Bash Completion is not installed.
Ok, I found it - I simply needed to do a source /etc/bash_completion
before or after the source <(kubectl completion bash)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With