不知道该把 Oh My Zsh 的补全放在哪里

问题描述 投票:0回答:3

我正在使用 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

autoload -U compinit && compinit
是否必须发生在之后我来源哦我的zsh?如果是这样,为什么? 🤔

zsh oh-my-zsh zshrc zsh-completion
3个回答
2
投票

上面的解决方案有效,谢谢@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 二进制文件升级时它会自动更新补全。


1
投票

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

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

0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.