Mac shell提示complete:13: command not found: compdef

Compdef is basically a function used by zsh for load the auto-completions. The completion system needs to be activated. If you’re using something like oh-my-zsh then this is already taken care of, otherwise you’ll need to add the following to your ~/.zshrc

实际解决方案,修改~/.zshrc 在开头增加下面的命令即可

autoload -Uz compinit
compinit

Completion functions can be registered manually by using the compdef function directly like this compdef . But compinit need to be autoloaded in context before using compdef.