不确定在Oh My Zsh中放置自动补全文件的位置

6

我正在使用zsh和oh my 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

autoload -U compinit && compinit 必须在我加载 oh my zsh 之后发生吗?如果是的话,为什么?


1
将此链接分享给其他用户 https://github.com/ohmyzsh/ohmyzsh/discussions/10774#discussioncomment-2356502 - Abdul Rauf
2个回答

1

你尝试把完成文件放在缓存目录以外了吗?

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

1

上面的解决方案可行,感谢 @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二进制文件升级时,它会自动更新完成。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接