Skip to content

Instantly share code, notes, and snippets.

@lordcirth
Last active July 4, 2018 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lordcirth/f157c369537c72e65ad1db6a4a124098 to your computer and use it in GitHub Desktop.
Save lordcirth/f157c369537c72e65ad1db6a4a124098 to your computer and use it in GitHub Desktop.
Taskwarrior RT hook
#!/usr/bin/env python
# Autodetect RT numbers and add the RT link as an annotation
import sys
import json
import re
added_task = json.loads(sys.stdin.readline())
rt_regex = re.compile(".*RT#?(\d+).*")
rt_baseurl = "https://rt.uwaterloo.ca/Ticket/Display.html?id="
#print added_task
desc = added_task['description']
if rt_regex.match(desc):
rt_number = rt_regex.match(desc).group(1) #Eg "RT800000"
rt_url = rt_baseurl + rt_number
entry_date = added_task['entry']
# TODO: Escape url /'s ?
annos = [ { "entry": entry_date, "description": rt_url } ]
added_task['annotations'] = annos
print "RT Link Added."
print(json.dumps(added_task))
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment