Ubuntu-like bash completion in Mac OS X?

I work in the terminal a fair bit, and one thing I really miss from the servers I usually work on is the comprehensive autocompletion bash provides on Ubuntu servers.

Are there any readymade tools that will add a similar level of completion to my Mac; containing at the very least command line arguments for built-in system utilities and developer tools (like git, xcodebuild, etc.)?


The easiest way is to install bash-completion from homebrew and follow the provided instructions.

Example output:

==> Downloading https://homebrew.bintray.com/bottles/bash-completion-1.3.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring bash-completion-1.3.mavericks.bottle.tar.gz
==> Caveats
Add the following lines to your ~/.bash_profile:
    if [ -f "$(brew --prefix)/etc/bash_completion" ]; then
        source "$(brew --prefix)/etc/bash_completion"
    fi

The Homebrew bash completion script has been installed to:
    /usr/local/etc/bash_completion.d

Bash completion has been installed to:
    /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/bash-completion/1.3: 188 files, 1.1M

Once you are done, you can create your own scripts under /usr/local/etc/bash_completion.d/.