Titus Stahl

A better Taskwarrior integration for Mutt

Starting from Richard Johnson’s description, I tried to come up with a more informative way to mark emails in Mutt as tasks in Taskwarrior.

As per Johnson’s advice, I use the following macro in my .muttrc:

1
macro index t "<pipe-message>mutt2task<enter> <save-message>+TODO<enter>"

This pipes the message through the mutt2task script and then moves it to the “TODO” folder.

My mutt2task script, however, looks as follows which captures both the subject and the sender of the email (which is often helpful when the subject is something generic):

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/bash
while IFS= read -r line; do
    if echo $line | grep -q "^From:" ; then
        # Only take the first line starting with "From: "
        if [ ! -n "$F" ] ; then
            F=`echo $line | grep 'From:' | awk -F: '{print $2}'`
        fi
    fi
    if echo $line | grep -q "^Subject:" ; then
        S=`echo $line | grep 'Subject:' | awk -F: '{print $2}'`
    fi
done
/usr/bin/task add +email due:today "E-mail $S (from $F)"