Rob*_*pek 12 zsh kubectl ubuntu-18.04
我已经在 Ubuntu 18.04 上安装了 zsh 和 oh my zsh。我想对 kubectl 使用自动完成功能。因此我已经添加source <(kubectl completion zsh)
到我的 ~/.zshrc 文件中。
执行此脚本时,zsh 收到以下错误:
complete:13: command not found: compdef
Run Code Online (Sandbox Code Playgroud)
kubectl 文档指出,当出现上述错误时,您应该将以下内容放在 .zshrc 文件的顶部:
autoload -Uz compinit
compinit
Run Code Online (Sandbox Code Playgroud)
执行此操作并重新启动终端后,我收到相同的错误。
在 git-issue 中,我发现以下内容对遇到常见问题的人有所帮助:
#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
Run Code Online (Sandbox Code Playgroud)
zsh 在运行脚本时记录以下内容:
kubescript:12457: command not found: _bash_comp
Run Code Online (Sandbox Code Playgroud)
不幸的是,这并没有解决我的问题。我还能做些什么来解决我的问题?甚至仍然:我该怎么做才能找出导致它的原因?
Ald*_*ein 18
我通过在 .zshrc 中使用以下代码修复了错误:
# K8s auto-complete
autoload -U +X compinit && compinit
source <(kubectl completion zsh)
Run Code Online (Sandbox Code Playgroud)
如果您使用 oh-my-zsh,您也可以使用oh-my-zsh 插件来完成。
小智 8
对于我的 OSX10.15.7
我做了类似的事情
vi ~/.zshrc
alias k=kubectl
autoload -U +X compinit && compinit
[[ /usr/local/bin/kubectl ]] && source <(kubectl completion zsh)
Run Code Online (Sandbox Code Playgroud)
奇迹般有效!
小智 7
我在安装 Angular CLI 后遇到了这个问题。原来 Angular 会在你的.zshrc
文件中添加一些东西。
如果您最近安装了 Angular CLI,请打开~/.zshrc
并删除 Angular CLI 添加的行。
小智 6
我遇到了同样的问题,更新 nvm 解决了
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
归档时间: |
|
查看次数: |
10382 次 |
最近记录: |