Adding OSX Automated Tasks for Git Commits

Suppose you work on a project where you are spending a lot of time focused on the code and fixing the bugs that keep popping up. It’s been a stressful day and you know it, the worst of it is when you forget to commit your changes you have been working on the whole day. Then keep on reading..

Now I’m proposing having an automated script which will run git status on your repo every night and checking if things need to be committed or not.

Here’s how you can do it:


  • OSX
  • Being comfortable writing shell scripts

1. Create an Automator

Now to create an automator for certain time, this is a bit different:

  1. Open Automator
  2. Choose Calendar
  3. Apple Script

For clearer way to create this automator, here’s a good video tutorial to create calendar automators for that.

on run {input, parameters}
	tell application "Terminal"
		if not (exists window 1) then reopen
		do script "gitcommit" in window 1
		delay 2
		close window 1
	end tell

	return input
end run

Now this automator is basically calling a gitcommit shell script which you on your machine.

2. Create Shell Script

Here’s what you do to create shell script:

  1. Open your favorite editor
  2. Write some code in it
  3. Close it, run chmod 700
  4. Copy and paste this very file in your usr/local/bin directory

Here’s the code for that shell script:



open -a Terminal

cd path/to/osx_actions
source ready.cfg

if [[ $var1 == 'commit' ]]; then
	cd path/to/your_repo
	if git status | grep -q 'nothing to commit'; then
	  echo "already up to date"
		echo "a commit needs to be done."
		git add -A
	 	git commit -m "$var2"

Now, this bash script goes and read from a cfg (configuration file) you have. In this case, I have my configuration file under osx_actions directory.

3. Create Configuration file

The cfg file basically looks like this:

var2="your default commit message"
  • var1 is a flag whether to perform commit operations or not. It takes values [commit/nocommit]
  • var2 takes the default commit message you have, off course if commits happened automatically without you changing this message you may need to do git commit –amend to edit that message for that commit be more meaningful.

Now you are almost done.

Just go to your calendar, and using the same mentioned video above:

4. Add Event to Calendar

Add an event to your calendar, choose whether you want it to repeat and how frequent and also add the time on which you want to this script to run.

Hope this tutorial helps.

Happy Coding 🙂

References Used


My New Chrome Extension – Tweet A Link

Tweet a Link Chrome Extension

Tweet a Link Chrome Extension

Just finished creating a new chrome extension which helps you tweet the urls you have one-click away. Rather than search for the Tweet button within pages, you have in your extensions in your browser.

No more you need to look for the tweet button or copy and paste the urls you like in order to tweet a certain page you like.

You can search it on the chrome store: “Tweet a link”

or you find it in the following link:

Enjoy your surf and sharing.