#!/bin/bash
TODOFILE=~/docs/todo
vim $TODOFILE
RETURNED=$?
if [ $RETURNED -ne 0 ]
then
# don't do much if vim didn't exit cleanly
echo "vim exited with code $RETURNED"
else
# otherwise commit the changes to the repository
# calculated the changes by counting the '-'s and '+' in the diff output
# then find the difference between these numbers with expr
ADDED=$(expr `svn diff ~/docs/todo |grep "^+"|wc -l` - `svn diff ~/docs/todo |grep "^-"|wc -l`)
# print a message before committing
echo "tasks added: $ADDED"
# do the actual commit
svn commit -m "todo list, tasks added: $ADDED" $TODOFILE
fi