Skip to content

Zsh

For zsh make sure these lines are present in your zsh config file (e.g ~/.zshrc or ~/.zprofile):

~/.zshrc
alias kubectl=kubecolor

Completions

Completion can be easily borrowed from the kubectl command by adding this to your ~/.zshrc file:

~/.zshrc
# Make "kubecolor" borrow the same completion logic as "kubectl"
compdef kubecolor=kubectl

As a prerequisite, you need kubectl completions installed. This can be achieved by either of these steps:

  • If your kubectl installation already came shipped with zsh completions (when you did apt install kubectl, dnf install kubectl, etc). Try out kubectl to see if the completions are already installed before you install it twice.

  • or you add this to ~/.zshrc:

    ~/.zshrc
    # This needs to be added before "compdef kubecolor=kubectl"
    source <(kubectl completion zsh)
  • or you can executed this:

    Terminal window
    kubectl completion zsh > "${fpath[1]}/_kubectl"