Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/bin/sh
# mutt_to_taskpaper.sh
# larryhynes.net/
# Important disclaimer: I have no idea what I'm doing
# This script will take the subject line of an email in mutt and add it to your Taskpaper inbox provided that "Inbox:" is the first line of your taskpaper file. The script can be called by a macro in mutt by adding `macro index T "<pipe-entry>~/mutt_to_taskpaper.sh<enter>"` to your .muttrc file, then T will add the todo item. You may need to make sure that the script is executable. You can adjust the path and name of your taskpaper file below to suit your setup.
TODOFILE=/Users/larry/todo.taskpaper
TEMPTODO=$(basename "$0")
LINE=1
TMPFILE=$(mktemp /tmp/"${TEMPTODO}".XXXXXX) || exit 1
grep '^Subject:' | awk -F '^Subject:' '{print $2;exit;}' | sed 's/^/ - Email:/' | unexpand -t4 > "$TMPFILE" || exit 1
ed -s $TODOFILE <<SHAZAM
${LINE}r $TMPFILE
w
SHAZAM
rm -f "$TMPFILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment