I am just getting started with Kubernetes and the
kubectl command specifically.
As there are so many flags and arguments, is there a way to enable autocompletion just like in
So for example when I type
kubectl get no[TAB] it would autocomplete
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $200 of credit to try our products over 60 days!
Yes, this is doable. What you would need to do is to first to make sure that you have the
bash-completionpackage installed. If not, you could install it with the following command:
After that, you could generate the required
kubectlcompletion rules with the
kubectl completion bashcommand, and then store the rules in your
.bashrcfile. You could use the following command to do that:
After that, use the
sourcecommand to activate the new rules:
Finally, if you were not now run
kubectl get no[TAB]it will be autocompleted.
This is indeed quite handy! Hope that this helps. Regards, Bobby
I would look at this page https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-autocomplete
You could use it for aliases as I usually use
kinstead of the full
kubectlcommand it is usefull