我在Ubuntu 18.04上安装了zsh和oh my zsh。我想为kubectl使用自动补全。因此,我已经将source <(kubectl completion zsh)
添加到我的~/.zshrc文件中。
执行此脚本时,zsh会收到以下错误:
complete:13: command not found: compdef
kubectl文档指出,当出现上述错误时,您应该将以下内容放在.zshrc文件的顶部:
autoload -Uz compinit
compinit
在执行此操作并重新启动终端后,我仍然遇到了同样的错误。
在一个git问题中,我发现以下方法帮助了一些人解决了常见的问题:
#This will perform chmod g-w for each file returned by compaudit to remove write access for group
compaudit | xargs -I % chmod g-w "%"
#This will perform chown to current user (Windows and Linux) for each file returned by compaudit
compaudit | xargs -I % chown $USER "%"
#Remove all dump files (which normally speed up initialization)
rm ~/.zcompdump*
#Regenerate completions file
compinit
运行脚本时,zsh记录了以下内容:
kubescript:12457: command not found: _bash_comp
不幸的是,这并没有解决我的问题。我还能做些什么来修复我的问题吗?或者甚至更好的问题是:我能做些什么来找出问题的根源?