Last active
February 3, 2021 16:00
-
-
Save kopiro/675538e2d8faa0b0b48ec5e58ea9f34c to your computer and use it in GitHub Desktop.
GIT notifications
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
#!/bin/bash | |
# For Windows, install https://github.com/Windos/BurntToast first | |
# Setup | |
PROJECT_DIR=~/Desktop/test-git | |
BRANCH_NAME="main" | |
CHECK_SEC=30 | |
# End setup | |
cd $PROJECT_DIR | |
notified_sha="" | |
notify() { | |
msg="You have changes to pull ($notified_sha)" | |
if [ "$(uname)" == "Darwin" ]; then | |
osascript -e "display notification \"$msg\"" | |
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then | |
notify-send "$msg" | |
elif [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]; then | |
powershell.exe "New-BurntToastNotification -Text \"$msg\"" | |
fi | |
} | |
while (true); do | |
git fetch origin | |
sha="$(git rev-parse $BRANCH_NAME@{upstream})" | |
if [ "$(git rev-parse HEAD)" != "$sha" ]; then | |
if [ "$notified_sha" != "$sha" ]; then | |
notified_sha="$sha" | |
notify | |
fi | |
fi | |
sleep $CHECK_SEC | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment