zsh4humans icon indicating copy to clipboard operation
zsh4humans copied to clipboard

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

Open dserodio opened this issue 2 years ago • 1 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

dserodio avatar May 10 '24 18:05 dserodio

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.

romkatv avatar May 10 '24 18:05 romkatv