Skip to content

Instantly share code, notes, and snippets.

@ofan
Created January 7, 2012 23:53
Show Gist options
  • Save ofan/1576524 to your computer and use it in GitHub Desktop.
Save ofan/1576524 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z "$TODO_FILE" ]; then
echo 'Environment variable TODO_FILE must be set.'
exit 1
fi
if [ "$#" == "0" ];then
cat $TODO_FILE
else
_TODO="• $@"
echo "$_TODO" >> $TODO_FILE
if [ -n "`which growlnotify`" ];then
echo -e "$_TODO" | growlnotify -t TODO
fi
if [ -n "$TODO_REPO" ];then
GIT_DIR="$TODO_REPO/.git" GIT_WORK_TREE="$TODO_REPO" git pull -q
GIT_DIR="$TODO_REPO/.git" GIT_WORK_TREE="$TODO_REPO" git commit -q -am 'Added new todos'
GIT_DIR="$TODO_REPO/.git" GIT_WORK_TREE="$TODO_REPO" git push -q &
fi
fi
#!/bin/bash
if [ "`uname -s`" == "Linux" ];then
SED=sed
else
SED=gsed
fi
if [ -z "$TODO_FILE" ]; then
echo "Environment variable TODO_FILE must be set"
exit 1
fi
_TODOS=`grep -i "$@" $TODO_FILE`
_NUM=`echo "$*" | grep '^[0-9]\+$'`
if [ -n "$_NUM" ];then
_SCRIPT="${_NUM}d"
else
_SCRIPT="/$*/Id"
fi
$SED -i -e "$_SCRIPT" $TODO_FILE
if [ -n "$TODO_REPO" ]; then
#GIT_DIR="$TODO_REPO/.git" GIT_WORK_TREE="$TODO_REPO" git pull -q
GIT_DIR="$TODO_REPO/.git" GIT_WORK_TREE="$TODO_REPO" git commit -q -am 'Removed todo'
GIT_DIR="$TODO_REPO/.git" GIT_WORK_TREE="$TODO_REPO" git push -q &
fi
if [ -n "`which growlnotify`" ]; then
echo -e "$_TODOS" | growlnotify -t DONE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment