After using my git-todo a bit I quickly became annoyed by empty TODO files so I added a check to remove the file if it is empty after leaving vim.
function git-todo {
OS=$(uname -s)
local SED_OPT
if [ "$OS" == "Darwin" ]; then
SED_OPT="-E"
fi
if [ "$OS" == "Linux" ]; then
SED_OPT="-r"
fi
local GIT_DIR=$(git rev-parse --git-dir)
if ! (( $? )); then
GIT_DIR=$(echo "$GIT_DIR" | sed $SED_OPT 's/\/?\.git$//')
if [ -z "$GIT_DIR" ]; then
GIT_DIR=.
fi
local TODO="$GIT_DIR/TODO.taskpaper"
vim "$TODO"
if [ ! -s "$TODO" ]; then
rm -f "$TODO"
fi
fi
}
Also on GitHub, .bashrc.d/git.sh.