Skip to content

Instantly share code, notes, and snippets.

@theevocater
Created December 3, 2013 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theevocater/7763047 to your computer and use it in GitHub Desktop.
Save theevocater/7763047 to your computer and use it in GitHub Desktop.
A snippet of bash to download the latest version of the git completion files locally and keep track of what version they are on
update_git_completion () {
# try to download the "correct" version of git completion
git_version=`git --version | cut -d" " -f3`
# check if we have the right version of git completion stuffs
if [[ -f git-completion.bash && -f git_completion_version && $git_version == `cat git_completion_version` ]]
then
echo "Up to date for $git_version"
else
# save the git version number
rm git_completion_version &>/dev/null
echo $git_version > git_completion_version
echo "Downloading git completion script for $git_version"
# here we fail (-f) quietly and save to same name as remote (-O)
curl -f -O https://raw.github.com/git/git/v$git_version/contrib/completion/git-completion.bash
curl -f -O https://raw.github.com/git/git/v$git_version/contrib/completion/git-prompt.sh
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment