Blog Post

Mark E-mails in Mutt as Tasks in Taskwarrior

OK, so I think most people know that I have grown quite fond of Taskwarrior for managing my Getting Things Done stuff. Many of you might also know that Mutt is my e-mail client of choice, for the past 15 years. Recently you saw a post on Planet Ubuntu by the rockstar Bryce Harrington concerning Mark emails in mutt as tasks in gtg. Well, I have had something similar, actually pretty much the same damn thing, just with a different GTD application. So without further ado, here is what you need to do in order to mark an email in mutt as a task in taskwarrior.

Setup Mutt Macro

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

What this does is set the t key, while in the index of mutt, as a macro. The macro pipes the email message to a script I wrote that strips the header from the message and adds that as a task. The save-message part saves the email to my TODO folder.

Setup Mutt2Task Script

/usr/bin/task add +email E-mail: $(grep 'Subject' $* | awk -F: '{print $2}')

What this does is call the command task add which adds a new task. The +email tags the task, and the E-mail: $(grep ‘Subject’ $* | awk -F: ‘{print $2}’) greps the Subject line and then prints the part after Subject: from the email, therefor just giving me the subject text. Make sure you place this script somewhere in $PATH and make it executable.

Make sure you add a TODO message folder in your mutt configuration so you can see the TODO messages.

This entry was posted in Application and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • ccm

    Really nice hint. I am actually using “Remember the Milk” for tracking my tasks, so I’ll have a look to modify it to use the rmilk api.

  • Pingback: Links 27/1/2010: KDE 4.4 RC3, GNOME Foundation Adds Bradley Kuhn | Boycott Novell()

  • Vikram Dhillon (dhillon-v10)

    Thanks a bunch Richard, as always this has been very helpful šŸ™‚

  • Tiger!P

    The mutt2task script does not work well with replies (containing an extra : in the subjectline.
    You could use $(grep ‘^Subject:’ $* | cut -d: -f 2-) instead.

    • Fabio Zanini

      I use a slightly different flavour:

      $(grep ‘Subject’ $* | sed ‘s/^Subject: //’)

      • Jhankins

        These all do weird things if there are multiple Subject headers. This one just extracts the first Subject: header, and eliminates the grep command, and works if the path to the file in $* contains whitespace:

        $(sed -n ‘/^Subject: /{s///p;q}’ “$*”)

        • Jhankins

          Gah! Don’t even need the “$*” for the mutt2task script, it’s reading the message from stdin. Mine now says:

          task add +email E-mail: $(sed -n ‘/^Subject: /{s///p;q}’)

  • Subscribe to

     Subscribe in a reader

    Or, subscribe via email:
    Enter your email address:

  • Archives

%d bloggers like this: