I forget things. A lot. I need a to do list tracker that works with me. So I wrote one. I, being me, used the technologies I use the most to make this happen: bash and git.
I had originally done the same thing with SVN, and that worked too, but I recently decided to go straight git. Probably the most important reason was that my SVN setup was world readable, and I didn’t want my todo list to be visible by everyone: If I need to remember the address for a baby sitter, or that I have to go and get an invasive surgical procedure, it is none of your business.
The set up is pretty simple. I have an account on a remote server where I have a git repository. Actually, I have two. One is a raw one, that acts as the keeper of the todo list, and one that pulls from the raw one as part of the publishing process. Two bash scripts, too, one of which runs on the server. This (slightly modified to not post my name and email everywhere) is the one that runs from a cron job, :
#!/bin/sh pushd ~/todo git fetch git rebase origin/master OUTFILE=/home/username/todo/todo.txt TITLE=`head -1 $OUTFILE` cat $OUTFILE | mail -s "$TITLE" email@hostname.com popd
Here’s the crontab
MAILTO="username@hostname.com" 0 5 * * 1-6 /home/username/todo.sh
thie is the script I run on my laptop. I call it add_todo, and keep it in $HOME/bin, which I have added to my path.
#!/bin/sh TODOLINE="" until [ -z "$1" ] # Until all parameters used up . . . do TODOLINE=$TODOLINE" $1 " shift done pushd $HOME/Documents/todo echo $TODOLINE >> todo.txt git add . git commit -m "TODO: $TODOLINE" git push ssh username@hostname.com todo/todo.sh
What is really interesting about this is what it says about git and ssh as message delivery system. This system has the following things built in: git push is idempotent: call it as many times as you wanat, a message gets delivered exactly once. Message delivery is a transaction and verifiable. You get a log of all activity. You get conflict notifications, and pretty good automated merging. It is secure by design. You get logging, history, and audit built in. It is efficient.
If you wanted, you could build a pretty efficient publish/subscribe system on top of branches.
Umm why not use “$@” instead of the $1 loop?
$@ is still an array and doesn’t become a single value. Doing it with the loop means I don’t have to put quotes around the todo Items list.