kubectl 5,150 generates its own completion script for bash, zsh, fish and PowerShell 55,538 . Completion asks the cluster, so Tab finishes resource names as well as commands. The popular k alias needs one extra line to keep completion working:
cat >> ~/.bashrc <<'EOF'
source <(kubectl completion bash)
alias k=kubectl
complete -o default -F __start_kubectl k
EOF
kubectl __complete get pods -n kube-system kube-a 2>/dev/null
kubectl kuberc set --section aliases --name pods --command get --prependarg pods \
--option output=wide
kubectl pods -n kube-system -l component=etcd | tr -s ' ' | cut -d' ' -f1,3,6,7kube-apiserver-l3-booknest-control-plane :4 Updated /home/dev/v5-ch6/lab/home/.kube/kuberc NAME STATUS IP NODE etcd-l3-booknest-control-plane Running 172.18.0.2 l3-booknest-control-plane
__complete is the hidden command that the completion script calls on every Tab; run by hand, it shows the candidates and a directive (:4 means "no file names"). The last two commands use kuberc (~/.kube/kuberc), beta and on by default since Kubernetes 1.34 5,150 : a preferences file, apart from the kubeconfig, for aliases and default flags (such as --interactive for every delete). Its aliases work in any shell and in scripts; KUBERC=off restores stock behavior.
krew 14,561 (github.com/kubernetes-sigs/krew (https://github.com/kubernetes-sigs/krew 7,041 )) manages kubectl plugins (any kubectl-<name> on the PATH becomes kubectl <name>), and k9s 592,566 (github.com/derailed/k9s (https://github.com/derailed/k9s 34,694 ), 0.51.0 here) is a terminal UI over the same kubeconfig.