Created
December 3, 2013 02:41
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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