#!/bin/sh # Copyright (C) 2014 Karl Fogel under opensource.org/licenses/BSD-2-Clause # Track one's progress in finishing TODO items recorded in Org Mode. # # Each run of this script compares my current Org Mode "TODO" items # (including both "TODO" and "STARTED", but not "DONE") with those # from 24 hours ago, and prints a summary of the difference, e.g.: # # $ ~/bin/todo-trend # 39 -> 33 (-6) # # In other words, a day ago I had 39 unfinished TODOs, now I have 33, # and the difference is that the count went down by 6. Progress! # # For this to work, your Org Mode files have to be under revision # control (the script assumes Subversion, but it could as easily be # Git or Mercurial or something else), and you'll need to tweak # ORG_FILES below to refer to whatever variable in Emacs lists all the # org files you care about for TODO purposes. For most people, # `org-agenda-files' would probably work. # Try replacing `kf-org-files' with `org-agenda-files' below, and of # course replace `kfogel' with your own username. (You can't just get # rid of the -u flag and its parameter, because then the --batch will # imply -q and your .emacs won't get loaded at all.) ORG_FILES=`emacs \ --batch -u kfogel \ --eval '(mapcar (lambda (x) (princ x) (princ "\n")) kf-org-files)' \ 2>/dev/null` TMP_DIR=${HOME}/private/scratch TODO_RE="^\*+ (TODO|STARTED) " # Get the total TODO count from 24 hours ago. rm -f ${TMP_DIR}/todo-trend-tmp for F in ${ORG_FILES}; do svn cat -r{"24 hours ago"} ${F} >> ${TMP_DIR}/todo-trend-tmp done THEN=`cat ${TMP_DIR}/todo-trend-tmp | grep -E "${TODO_RE}" | wc -l` rm -f ${TMP_DIR}/todo-trend-tmp # Get the total TODO count now. NOW=`cat ${ORG_FILES} | grep -E "${TODO_RE}" | wc -l` # Compare. echo "${THEN} -> ${NOW} (`dc -e \"${NOW} ${THEN} - p\"`)"