Skip to content

Shell Completion

Omri Bornstein edited this page Oct 23, 2022 · 3 revisions

macOS

Please make sure you follow Homebrew’s documentation, which is mirrored below.

bash

To make Homebrew’s completions available in bash, you must source the definitions as part of your shell’s startup. Add the following to your ~/.bash_profile:

for COMPLETION in "$(brew --prefix)/etc/bash_completion.d/"*; do
    [[ -r "${COMPLETION}" ]] && source "${COMPLETION}"
done

zsh

  1. Edit ~/.zshrc such that FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}" is called before autoload -Uz compinit; compinit
    FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
    autoload -Uz compinit; compinit
  2. In my case, the following configuration worked the best, since other tools (such as vagrant) keep the completions in other places:
    FPATH="$(brew --prefix)/share/zsh/site-functions:$(brew --prefix)/share/zsh-completions:${FPATH}"
    autoload -Uz compinit; compinit
  3. You may also need to forcibly rebuild zcompdump:
    rm -f ~/.zcompdump; compinit
  4. Additionally, if you receive zsh compinit: insecure directories warnings when attempting to load these completions, you may need to run this:
    chmod -R go-w "$(brew --prefix)/share"

Clone this wiki locally