romkatv / zsh4humans

A turnkey configuration for Zsh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when defining `compdef kubecolor=kubectl` in .zshrc

dserodio opened this issue · comments

I have a snippet in my .zshrc that defines compdef kubecolor=kubectl if kubecolor is installed:

if (( $+commands[kubecolor] )); then
    alias k=kubecolor
    compdef kubecolor=kubectl
    export KUBECOLOR_OBJ_FRESH=12h # highlight resources newer than 12h
else
    alias k=kubectl
fi

This gives the following error: compdef: unknown command or service: kubectl. If I execute the compdef kubecolor=kubectl command in the interactive shell after it's been initialized, I don't get this error.

kubectl is installed by google-cloud-sdk, which is installed via Homebrew:

$ which kubectl
/opt/homebrew/share/google-cloud-sdk/bin/kubectl

I'm afraid it's not something I'm willing to debug. If you do find out the reason or any clues, please post a comment.