不确定将 Oh My Zsh 的补全放在哪里

发布于 2025-01-13 21:35:49 字数 1208 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

想念有你 2025-01-20 21:35:49

上面的解决方案有效,谢谢@Nishant Mittal,但我怀疑在 omz 更新后它是否会保留。我找到了一个更稳定的解决方案,感谢 kubectl 插件。

cat ${HOME}/.oh-my-zsh/custom/plugins/dind/dind.plugin.zsh
dind completion zsh 2> /dev/null >| "$ZSH_CACHE_DIR/completions/_dind" &| 

然后将其添加到 ~/.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.

cat ${HOME}/.oh-my-zsh/custom/plugins/dind/dind.plugin.zsh
dind completion zsh 2> /dev/null >| "$ZSH_CACHE_DIR/completions/_dind" &| 

Then add it in plugins section of your ~/.zshrc .
I presume it will update the completion automatically when dind binary is upgraded.

仙气飘飘 2025-01-20 21:35:49

您是否尝试过将完成内容不在缓存目录中。

kind complete zsh > ~/.oh-my-zsh/completions/_kind

Have you tried putting the completions not in the cache directory.

kind complete zsh > ~/.oh-my-zsh/completions/_kind
扶醉桌前 2025-01-20 21:35:49

echo 'source <(kind finish zsh)' >>~/.zshrc

echo 'source <(kind completion zsh )' >>~/.zshrc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文