Skip to content

Instantly share code, notes, and snippets.

@kbambz
Last active December 22, 2015 19:29
Show Gist options
  • Select an option

  • Save kbambz/6520086 to your computer and use it in GitHub Desktop.

Select an option

Save kbambz/6520086 to your computer and use it in GitHub Desktop.
Install Git and setup bash autocompletion on Mac OS X using Homebrew.
#!/bin/bash
#
# Ensure Homebrew is installed
#
which -s brew
if [[ $? != 0 ]]; then
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew doctor
else
brew update
fi
#
# Ensure Git is installed
#
which -s git || brew install git
#
# Setup bash autocompletion for Git
#
if [[ ! -f ~/.git-completion.bash ]]; then
echo "$(curl -fsSL https://raw.github.com/git/git/master/contrib/completion/git-completion.bash)" > ~/.git-completion.bash
fi
grep ".git-completion.bash" ~/.bashrc > /dev/null || echo "source ~/.git-completion.bash" >> ~/.bashrc && . ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment