Not sure where to put completions with Oh My Zsh

Viewed 861

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?

1 Answers

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

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