Create github issues from mutt

A few month ago, I switched my email workflow to mutt. It’s quite nice to never leave the command line, right?

I’ve been using quite a lot, to turn emails into taskwarrior tasks.

Now, I’ve seen myself quite often turning email into github issues, so being the typical geek-programmer type, I automated this with a mutt script that convert an emails into a github issue.

It needs a little bit of manual editing to get this working:

  • install hub
  • set GITHUB_TOKEN, or GITHUB_USER and GITHUB_PASSWORD environment variables
  • modify the last part of the script that determines the project from the email content and cd to the project’s directory.

The gist:

The code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

## About
# Use the content of an email to create a github issue
## Usage
# add this to your .muttrc:
# macro index,pager \ei "~/path/to/"
# Requires the `hub` CLI tool:

# import libraries
import sys
import time
import email
import os
from email.header import decode_header
from subprocess import call, Popen, PIPE
import re

# read from stdin and parse subject
message =
message = email.message_from_string(message)

body = None
for part in message.walk():
if part.get_content_type() == "text/plain":
if body is None:
body = ""
charset = part.get_content_charset()
if charset is None:
charset = 'ASCII'
body += unicode(
charset, 'replace'

message = message['Subject']

# decode internationalized subject and transform ascii into utf8
message = decode_header(message)
message = ' '.join([ unicode(t[0], t[1] or 'ASCII' ) for t in message ])
message = message.encode('utf8')

message = '%s\n%s' % (message, body)
if 'my-project-id' in message or 'some-other-string' in message:
print 'Project X detected'
print 'Cannot recognize the project in email...'
print message

call(['hub', 'issue', 'create', '--edit', '-m', message])

I’m a consultant and developer for Mobile, Web, Games and Apps projects. I co-founded Fovea 8 years ago.

Posted in Blog