Skip to content

Instantly share code, notes, and snippets.

@wbsch
Created March 21, 2015 21:22
Show Gist options
  • Save wbsch/f592b37c249decf65395 to your computer and use it in GitHub Desktop.
Save wbsch/f592b37c249decf65395 to your computer and use it in GitHub Desktop.
Proof of concept for an interactive Taskwarrior hook. Hackish and potentially problematic, but it works.
#!/usr/bin/env python
#
# PoC: Interactive on-add hook
import json
import sys
t = json.loads(sys.stdin.readline())
real_stdin = open("/dev/tty", "r")
real_stdout = open("/dev/tty", "w")
if "teh" in t['description']:
real_stdout.write('You misspelled "the". Should I correct that for you? [Y/n] ')
real_stdout.flush()
i = real_stdin.readline().rstrip()
if i == "y" or i == "Y" or i == "":
t['description'] = t['description'].replace("teh", "the")
print(json.dumps(t))
@linuxcaffe
Copy link

interesting! Proof of concept, you say?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment