Created
February 1, 2017 22:46
-
-
Save 32teeth/6da4d9140f18f6179703fb256378bf05 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
#!/bin/zsh | |
export NC='\e[0m' # No Color | |
export WHITE='\e[1;37m' | |
export BLUE='\e[1;34m' | |
export GREEN='\e[0;32m' | |
export YELLOW='\e[1;33m' | |
export TODAY=`date +%A\ %B\ %Y\ %T` | |
export NOTIFIER=0 | |
export PLAIN=๐บ | |
export HAPPY=๐ธ | |
export WINK=๐ผ | |
export LOVE=๐ป | |
export SAD=๐ฟ | |
export EVIL=๐ผ | |
export ANGRY=๐พ | |
export WAIT=๐ฝ | |
clear | |
main() { | |
while true; do | |
echo "\n ${WHITE}Welcome to ${PLAIN} autogit${NC}\n" | |
echo " ${WINK} checking for required packages" | |
if (brew list | grep -q 'terminal-notifier') | |
then | |
NOTIFIER=1 | |
echo " ${LOVE} required packages installed!" | |
fi | |
if [ "$NOTIFIER" = "0" ] | |
then | |
echo " ${SAD} ${RED}required packages NOT installed!${NC}" | |
echo " ${EVIL} installing required packages" | |
fi | |
echo "--------------------------------------------------------------------------" | |
echo "\n ${YELLO}${WAIT} autogit says:${NC} polling for changes!\n" | |
echo "--------------------------------------------------------------------------\n\n" | |
STATUS=($(git status -s)) | |
while [ "${#STATUS[@]}" = 0 ]; | |
do | |
STATUS=($(git status -s)) | |
done | |
if [ "${#STATUS[@]}" > 0 ] | |
then | |
terminal-notifier -title "${WINK} autogit says:" -message "you have some changes waiting" -sound "default" | |
echo "\n ${GREEN}${WINK} autogit says:${NC} you got changes" | |
echo -n " ${WHITE}run autogit?${NC} " | |
select COMMIT in "Yes" "No"; do | |
case $COMMIT in | |
Yes ) break;; | |
No ) exit;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
fi | |
echo " ${GREEN}${PLAIN} autogit says:${NC} looks like a commit message" | |
echo -n "\n ${WHITE}Message: ${NC}" | |
while read MESSAGE && [ -z "$MESSAGE" ]; do :; done | |
echo "\n ${GREEN}${PLAIN} autogit says:${NC} looks like a commit description (can be blank)" | |
echo -n "\n ${WHITE}Description: ${NC}" | |
read DESCRIPTION | |
echo "\n ${GREEN}${WAIT} autogit says:${NC} adding files" | |
git add . | |
sleep 1 | |
echo " ${GREEN}${WAIT} autogit says:${NC} commiting files with:" | |
echo " ${WHITE}message:${NC} ${MESSAGE}" | |
echo " ${WHITE}description:${NC} ${DESCRIPTION}" | |
git commit -a -m "${MESSAGE}" -m "${DESCRIPTION}" -q | |
sleep 1 | |
echo " ${GREEN}${WAIT} autogit says:${NC} pushing them files" | |
git push -u -q | |
sleep 1 | |
HASH=`git log -n1 --format="%h"` | |
echo " ${GREEN}${HAPPY} autogit says:${NC} heres the hash ${WHITE}${HASH}${NC}" | |
terminal-notifier -title "${HAPPY} autogit says:" -message "'${HASH} - ${MESSAGE}' was success. thanks, i am done." -sound "default" | |
sleep 1 | |
clear | |
echo "--------------------------------------------------------------------------" | |
echo "\n ${GREEN}${HAPPY} autogit says:${NC} thanks for using autogit!\n" | |
echo "--------------------------------------------------------------------------\n\n" | |
sleep 1 | |
clear | |
done | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment