Skip to content

Instantly share code, notes, and snippets.

Avatar

Wilhelm Schürmann wbsch

View GitHub Profile
@wbsch
wbsch / taskwarrior_xmpp_bot.py
Created Nov 19, 2012
taskwarrior <---> XMPP bridge in python. Proof of concept, no error checking :)
View taskwarrior_xmpp_bot.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sleekxmpp
import subprocess
import time
class TWBot(sleekxmpp.ClientXMPP):
def __init__(self, jid, password, whitelist):
@wbsch
wbsch / datefilter.py
Created May 5, 2013
Filter Taskwarrior tasks completed before a certain time. Reads from STDIN, outputs to STDOUT. Backups recommended ;)
View datefilter.py
#!/usr/bin/env python
import re
import sys
import time
if len(sys.argv) < 2:
print "Example usage:"
print sys.argv[0], "2013-05-05 < ~/.task/completed.data > ~/.task/completed.data.tmp && mv ~/.task/completed.data.tmp ~/.task/completed.data"
sys.exit(1)
@wbsch
wbsch / filter.py
Last active Dec 17, 2015
Filter Taskwarrior tasks completed/deleted before a certain time. Reads from STDIN, outputs to STDOUT. Backups still recommended. More detailed documentation and options.
View filter.py
#!/usr/bin/env python
import re
import sys
import time
if len(sys.argv) < 3 or sys.argv[2] not in ["all", "completed", "deleted"]:
sys.stderr.write("Reads data in Taskwarrior format from STDIN and writes to STDOUT only those tasks completed/deleted after the supplied date.\n\n")
sys.stderr.write("### Usage: " + sys.argv[0] + " <Y-m-d> <all|completed|deleted>\n")
sys.stderr.write("Where \"all\" filters all tasks and \"completed\"/\"deleted\" only those with the status set to the keyword specified.\n\n")
sys.stderr.write("### Example usage:\n")
@wbsch
wbsch / on-modify.timetrack.py
Last active Nov 12, 2020
Time tracking hook script for Taskwarrior that outputs ledger timelog formatted data.
View on-modify.timetrack.py
#!/usr/bin/env python
#
# Writes task start/stop times to a timelog formatted file.
# You might need to adjust LEDGERFILE, or set the TIMELOG environment variable.
#
# Example reports, after using start/stop on a task:
# ledger -f /path/to/timelog.ledger print
# ledger -f /path/to/timelog.ledger register
#
# Projects, tags, and UUIDs are fully supported and queryable from ledger.
@wbsch
wbsch / on-add.project_pwd.py
Created Mar 5, 2015
Example for an on-add hook that sets the project of newly added tasks to the current directory's name by default.
View on-add.project_pwd.py
#!/usr/bin/env python
import json
import os
import sys
t = json.loads(sys.stdin.readline())
if not 'project' in t:
t['project'] = os.path.basename(os.getcwd())
@wbsch
wbsch / on-modify.blocks_attr.py
Last active Nov 17, 2020
Taskwarrior hook script that adds a "blocks:" pseudo-attribute for adding/modifying tasks.
View on-modify.blocks_attr.py
#!/usr/bin/env python
#
# Adds the ability to add / modify tasks using a "blocks:" attribute,
# the opposite of "depends:".
#
# This script acts as an on-modify, on-add and on-launch hook at the same time.
#
### SETUP
# Save this file as
# ~/.task/hooks/on-modify.blocks_attr.py
@wbsch
wbsch / on-add_interactivity.py
Created Mar 21, 2015
Proof of concept for an interactive Taskwarrior hook. Hackish and potentially problematic, but it works.
View on-add_interactivity.py
#!/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")
@wbsch
wbsch / on-add_inline_tags.py
Last active Sep 4, 2015
Proof of concept for a Taskwarrior on-add hook that allows for "inline tags" when adding tasks
View on-add_inline_tags.py
#!/usr/bin/env python
#
# PoC for "inline tags", as described in TW-1357
# https://bug.tasktools.org/browse/TW-1357
#
# Turns
# $ task add I saw @bob in the @garden
# Into the equivalent of
# $ task add I saw bob in the garden +bob +garden
@wbsch
wbsch / on-exit_git.py
Last active Nov 16, 2020
Proof of concept for a Taskwarrior on-exit hook that manages a git repository in ~/.task
View on-exit_git.py
#!/usr/bin/env python
#
# PoC: Manage a git repository in ~/.task that gets updated on changes.
# Only pending.data and completed.data are included by default.
# You can use "git add" to add whatever files you want to track in your
# task folder.
#
# Inspired by https://gist.github.com/Unode/9366218
#
# Works with any Taskwarrior version that supports hooks.
View on-modify_macro_expand.py
#!/usr/bin/env python
# Proof of Concept for expanding aliases in annotations.
#
# See https://bug.tasktools.org/browse/TW-77
import json
import re
import sys
old = json.loads(sys.stdin.readline())
new = json.loads(sys.stdin.readline())