Skip to content

Instantly share code, notes, and snippets.

@funguscolander
Last active March 2, 2021 19:58
Show Gist options
  • Save funguscolander/2a972d8b229d139ed3630123632bd802 to your computer and use it in GitHub Desktop.
Save funguscolander/2a972d8b229d139ed3630123632bd802 to your computer and use it in GitHub Desktop.
Taskwarrior hook to add projectless tasks to the project `none` upon their creation or the removal of their project. This will remove the empty space in the projects column of reports for projectless tasks.
#!/usr/bin/env python3
# adds a project called 'none' to any task that was created without a project
# source: https://www.reddit.com/r/commandline/comments/jcpd9q/taskwarrior_is_perfect/g9s7o1g/?context=3
import json
import sys
task = json.loads(sys.stdin.readline())
if 'project' not in task:
task['project'] = 'none'
msg = "No project found - added the 'none' project to the task"
else:
msg = ''
print(json.dumps(task))
if msg:
print(msg)
sys.exit(0)
#!/usr/bin/env python3
# adds a project called 'none' to any task who's project was removed
# source: https://www.reddit.com/r/commandline/comments/jcpd9q/taskwarrior_is_perfect/g9s7o1g/?context=3
import json
import sys
old = json.loads(sys.stdin.readline())
new = json.loads(sys.stdin.readline())
if 'project' not in new:
new['project'] = 'none'
msg = "No project found in modified task - added the 'none' project to the task"
else:
msg = ''
print(json.dumps(new))
if msg:
print(msg)
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment