不确定将 Oh My Zsh 的补全放在哪里
我正在使用 zsh,哦我的 zsh,我对在哪里放置完成文件有点困惑。
例如,在安装 kind
时,我这样做:
brew install kind
kind complete zsh > ~/.oh-my-zsh/cache/completions/_kind
并且我希望 kind
的补全将开始工作。我是否将它们放在错误的目录中?
如果我这样做 autoload -U compinit && compinit
在当前终端中,完成工作直到我重新启动终端为止。
我认为我的 .zshrc 非常标准,这基本上就是我所得到的:
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export ZSH="$HOME/.oh-my-zsh"
DISABLE_MAGIC_FUNCTIONS="true"
plugins=(
git
gh
docker
docker-compose
kubectl
helm
dotnet
node
npm
github
zsh-syntax-highlighting
zsh-autosuggestions
history-substring-search
terraform)
autoload -U compinit && compinit
source $ZSH/oh-my-zsh.sh
Does the autoload -U compinit && compinit 必须发生在我的 zsh 源代码之后?如果是这样,为什么?
I'm using zsh and oh my zsh, and I'm a bit confused about where to put completion files.
For example, when installing kind
, I'm doing this:
brew install kind
kind complete zsh > ~/.oh-my-zsh/cache/completions/_kind
And I expect that completions for kind
would start working. Am I putting them in the wrong dir?
If I do autoload -U compinit && compinit
in the current terminal, completions work until I restart the terminal.
My .zshrc
is pretty standard I think, this is basically what I've got:
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export ZSH="$HOME/.oh-my-zsh"
DISABLE_MAGIC_FUNCTIONS="true"
plugins=(
git
gh
docker
docker-compose
kubectl
helm
dotnet
node
npm
github
zsh-syntax-highlighting
zsh-autosuggestions
history-substring-search
terraform)
autoload -U compinit && compinit
source $ZSH/oh-my-zsh.sh
Does the autoload -U compinit && compinit
has to happen after I source oh my zsh? If so, why? ????
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
上面的解决方案有效,谢谢@Nishant Mittal,但我怀疑在 omz 更新后它是否会保留。我找到了一个更稳定的解决方案,感谢 kubectl 插件。
然后将其添加到 ~/.zshrc 的插件部分中。
我认为当 dind 二进制文件升级时它会自动更新补全。
The solution above is working, thank you @Nishant Mittal, but I doubt it will remain after an omz update. I found a more stable solution, thanks kubectl plugin.
Then add it in plugins section of your ~/.zshrc .
I presume it will update the completion automatically when dind binary is upgraded.
您是否尝试过将完成内容不在缓存目录中。
Have you tried putting the completions not in the cache directory.
echo 'source <(kind finish zsh)' >>~/.zshrc
echo 'source <(kind completion zsh )' >>~/.zshrc