Last active
November 3, 2016 19:32
-
-
Save timolehto/4e66c324b11f7e59f15715594491ad5e to your computer and use it in GitHub Desktop.
This file contains 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
#You should copy-paste or source this to/from your ~/.bash_profile (or whatever you're using) | |
git_complete_dir="$HOME/.git-completion" | |
if [ ! -d "$git_complete_dir" ]; then | |
mkdir "$git_complete_dir" | |
fi | |
command pushd "$git_complete_dir" > /dev/null | |
now="$(date +%Y-%m-%d)" | |
if [ "$(tail -1 check.log)" != "$now" ]; then | |
echo "$now" >> check.log | |
echo "Checking for updates..." | |
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o new-git-completion.bash | |
echo "downloaded latest version... diffing with current.." | |
if ! diff -r new-git-completion.bash git-completion.bash >/dev/null; then | |
echo "versions differ" | |
read -p "git-completion has been updated, do you want to apply this update? (y/yes): " CONDITION; | |
CONDITION=$(tr '[:upper:]' '[:lower:]' <<< "$CONDITION") | |
echo "Normalised comndition: $CONDITION" | |
case "$CONDITION" in | |
yes|y) | |
echo "Updating git-completion..." | |
mv git-completion.bash git-completion.bash.backup | |
mv new-git-completion.bash git-completion.bash | |
echo "done." | |
;; | |
*) | |
echo "Ok, doing nothing then." | |
;; | |
esac | |
fi | |
fi | |
. git-completion.bash | |
command popd > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment