Skip to content

Instantly share code, notes, and snippets.

@johngibb
Last active December 10, 2025 00:20
Show Gist options
  • Select an option

  • Save johngibb/972430 to your computer and use it in GitHub Desktop.

Select an option

Save johngibb/972430 to your computer and use it in GitHub Desktop.
Mac OS X - Install Git Completion
URL="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash"
PROFILE="$HOME/.profile"
echo "Downloading git-completion..."
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 "$PROFILE" ]] && grep -q "$SOURCE_LINE" "$PROFILE"; then
echo "Already added to bash profile."
else
echo "Adding to bash profile..."
echo "$SOURCE_LINE" >> "$PROFILE"
fi
echo "Reloading bash profile..."
source "$PROFILE"
echo
echo "Successfully installed."
echo "Git auto-completion should be all set!"
@ajmichels

Copy link
Copy Markdown

NM. I recently added a .bash_profile file which is now running instead of my .profile script. http://stackoverflow.com/questions/18773051/how-to-make-os-x-to-read-bash-profile-not-profile-file

I added "source ~/.profile" to .bash_profile and everything is happy again.

And the git completion is working. :)

@vicaya

vicaya commented Aug 13, 2014

Copy link
Copy Markdown

You'll need to add -L to the curl command to follow redirect now

@tashia

tashia commented Nov 6, 2015

Copy link
Copy Markdown

Thanks! I am glad I found this one! I have tried so many links, this one finally make the autocompletion work!

@Sudharma

Copy link
Copy Markdown

Thanks worked for me on Mac.

@Kiodaddy

Copy link
Copy Markdown

Thanks working fine on Mac, i was having issue but corrected it.

@Maxon4eg

Copy link
Copy Markdown

Thank you !
works on mac

ghost commented Jan 18, 2018

Copy link
Copy Markdown

Thank you!
It works for me on mac.

@dnlglsn

dnlglsn commented Feb 1, 2018

Copy link
Copy Markdown

Thanks! This works on OSX high sierra too.

@A6Brgeuka

Copy link
Copy Markdown

works well, ty!

@HerbertKoelman

Copy link
Copy Markdown

Very cool, thanks for the information :-)

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