Skip to content

Instantly share code, notes, and snippets.

@cellularmitosis
Last active June 9, 2020 10:22
Show Gist options
  • Save cellularmitosis/4bbfba8d692664ebe86df265245a2bea to your computer and use it in GitHub Desktop.
Save cellularmitosis/4bbfba8d692664ebe86df265245a2bea to your computer and use it in GitHub Desktop.
Bash completion in Homebrew

Blog 2019/4/24

<- previous | index | next ->

Bash completion in Homebrew

$ brew install bash-completion

You'll need to make sure /usr/local/etc/profile.d/* are being sourced.

I do this by using a ~/.bash_profile which looks like this:

source ${HOME}/.bashrc

for i in ${HOME}/.bash_profile.d/*
do
    source "${i}"
done

and then creating ~/.bash_profile.d/homebrew.bash:

for i in `brew --prefix`/etc/profile.d/*
do
    source "${i}"
done

(I use the .bash vs. .sh convention to distinguish between "files which you can source" vs. "scripts which you can run".)

To test that this worked, start a new shell and type dd i<TAB><TAB>. The completion options should be ibs= if=.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment