Skip to content

January 19, 2015

3

Bash Completion on OS X With Brew

I live and breath OS X on a daily basis, with a large portion of my work revolving around the command line using mostly tools which I’ve installed with brew. Bash completion has likely saved me days worth of time over the past decade or so. Little did I know, up until recently, however, that there is an official tap with completion scripts (in addition to the ones which come with individual recipes such as git) which can be installed for tools like docker, vagrant and grunt. Using it is dog simple. To start with you’ll want to go ahead and install bash-completion (if you haven’t already) and then tap homebrew/completion to gain access to these additional formulae:

$ brew install bash-completion
$ brew tap homebrew/completions

After you run that first command, in typical brew fashion, it will request that you add the following tidbit to your ~/.bash_profile. Don’t forget this part. It’s critical!

if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi

Once you’ve done this, you’ll be able to install the additional completion scripts. You can find a complete list of these over here on GitHub. Happy tabbing!

Read more from Development
3 Comments Post a comment
  1. Feb 2 2015

    Nifty. I’ve set this up on my machine. Thanks for sharing.

    Reply
  2. May 12 2015

    Nice tip ! I had it to my favourites
    I’m from Ubuntu and now it’s nice 😉

    Reply
  3. runnerdave
    Mar 16 2016

    thanks a lot, coming from ubuntu as well, you can also add that people need to run . ~/.bash_profile after the change for the variable to work

    Reply

Share your thoughts, post a comment.

(required)
(required)

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments