How To GIT Commit and Push to Branch on Macbook Lid Close

in #programming7 years ago (edited)

Alright, this is something I wanted to do because I sometimes forget to push changes or perhaps didn't want to push to the branch I'm working on. I'll show you how to auto commit and push to a specific branch on macbook lid close. In fact you can run any script on close. Its a simple 3 step process

  1. Install https://github.com/fishman/sleepwatcher
  2. Create a SH script file to run on lid close (here's mine)
#!/usr/bin/env sh

cd /path/to/branch
git checkout -b auto-save
git push -f --set-upstream origin auto-save
git add .
git commit -m "sleep autosave" --no-verify
git push -f

3 Run this command at mac startup (https://stackoverflow.com/questions/6442364/running-script-upon-login-mac)
/usr/local/sbin/sleepwatcher --verbose --sleep ./path-to-script.sh

Enjoy!

Propane-Saftey.jpg

Sort:  

Congratulations @donmesswithabeer! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

3 years on Steem - The distribution of commemorative badges has begun!
Happy Birthday! The Steem blockchain is running for 3 years.
Vote for @Steemitboard as a witness to get one more award and increased upvotes!