6

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?

Joel
  • 8,502
  • 11
  • 66
  • 115
  • 1
    Linking this for other users https://github.com/ohmyzsh/ohmyzsh/discussions/10774#discussioncomment-2356502 – Abdul Rauf Oct 03 '22 at 07:05

2 Answers2

1

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

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

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.

Storager
  • 3
  • 4