Skip to content

Instantly share code, notes, and snippets.

@y-takagi
Forked from abellmann/install-git-completion.sh
Created September 22, 2011 08:32
Show Gist options
  • Save y-takagi/1234341 to your computer and use it in GitHub Desktop.
Save y-takagi/1234341 to your computer and use it in GitHub Desktop.
Mac OS X - Install Git Completion
GIT_VERSION=`git --version | awk '{print $3}'`
URL="https://raw.github.com/git/git/v$GIT_VERSION/contrib/completion/git-completion.bash"
BASHRC="$HOME/.bashrc"
echo "Downloading git-completion for git version: $GIT_VERSION..."
if ! curl "$URL" --silent --output "$HOME/.git-completion.bash"; then
echo "ERROR: Couldn't download completion script. Make sure you have a working internet connection." && exit 1
fi
SOURCE_LINE="source ~/.git-completion.bash"
if [[ -f "$BASHRC" ]] && grep -q "$SOURCE_LINE" "$BASHRC"; then
echo "Already added to bashrc."
else
echo "Adding to bashrc..."
echo "$SOURCE_LINE" >> "$BASHRC"
fi
echo "Reloading bashrc..."
source "$BASHRC"
echo
echo "Successfully installed."
echo "Git auto-completion should be all set!"
@y-takagi
Copy link
Author

i think its better to add "source ~/.git-completion.bash" to $HOME/.bashrc than $HOME/.profile

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