Skip to content

Instantly share code, notes, and snippets.

@varunagrawal
Last active September 4, 2021 16:59
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save varunagrawal/2b93c5dc721520ff6876e940c420ab05 to your computer and use it in GitHub Desktop.
Save varunagrawal/2b93c5dc721520ff6876e940c420ab05 to your computer and use it in GitHub Desktop.
Script to sync Taskwarrior after each operation
#!/usr/bin/env python3
# This hooks script syncs task warrior to the configured task server.
# The on-exit event is triggered once, after all processing is complete.
# Make sure hooks are enabled and this hook script is executable.
# Run `task diag` for diagnostics on the hook.
import sys
import json
import subprocess
try:
tasks = json.loads(sys.stdin.readline())
except:
# No input
pass
# Call the `sync` command
# hooks=0 ensures that the sync command doesn't call the on-exit hook
# verbose=nothing sets the verbosity to print nothing at all
subprocess.call(["task", "rc.hooks=0", "rc.verbose=nothing", "sync"])
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment