Skip to content

Instantly share code, notes, and snippets.

@larryhynes
Last active March 27, 2021 02:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larryhynes/7608022 to your computer and use it in GitHub Desktop.
Save larryhynes/7608022 to your computer and use it in GitHub Desktop.
#!/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