How to fix: /dev/fd/12:2: command not found: compdef error
This post says that we can use the completion for the kubectl by executing echo "source <(kubectl completion zsh)" >> ~/.zshrc.
However, in my environment, MacOS and zsh shell, I encountered the following error.
/dev/fd/12:2: command not found: compdef /dev/fd/12:18: command not found: compdef
To resolve this problem, I first installed zsh-completions by running brew install zsh-completions and writing autoload -Uz compinit && compinit in the ~/.zshrc file.
autoload -Uz compinit && compinit source <(kubectl completion zsh)