Skip to content

Instantly share code, notes, and snippets.

@andreas-wilm
Created April 16, 2019 09:03
Show Gist options
  • Save andreas-wilm/86c3af73a21a17e5b960263f12916452 to your computer and use it in GitHub Desktop.
Save andreas-wilm/86c3af73a21a17e5b960263f12916452 to your computer and use it in GitHub Desktop.
on-add hook to add default priority to taskwarrior tasks if not specified
#!/usr/bin/env python
import sys
import json
DEF_PRIO = 'M'
added_task = json.loads(sys.stdin.readline())
if 'priority' not in added_task:
sys.stderr.write("Adding default priority: {}\n".format(DEF_PRIO))
added_task['priority'] = DEF_PRIO
# see https://taskwarrior.org/docs/hooks_guide.html
# save as .task/hooks/on-add
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