--- /dev/null
+Copyright 2015 Tomas Babej
+http://github.com/tbabej/taskwarrior-shift-all-recurrence-hook
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- /dev/null
+Taskwarrior Shift All Recurrence Attributes Hook
+------------------------------------------------
+
+This is a hook for TaskWarrior (http://www.taskwarrior.org),
+which allow your recurrent tasks to inherit ``wait``, ``scheduled``
+and ``until`` attributes from the parent.
+
+Install
+-------
+
+Note: This hook has been rewritten to leverage taskpirate, for greater hook efficiency.
+Please see https://github.com/tbabej/taskpirate for instructions. Don't worry, it's straightforward.
+
+```
+git clone https://github.com/tbabej/taskwarrior-shift-all-recurrence-hook.git
+cp taskwarrior-shift-all-recurrence-hook/on-* ~/.task/hooks/
+```
+
+This hook leverages tasklib, so you need to install that too:
+
+```
+pip install tasklib
+```
+
+Use case
+--------
+
+Consider you have a periodic task, which is valid only for the certain day,
+e.g. on every Sunday you go running.
+
+```
+$ task add due:sunday recur:weekly
+```
+
+However, TaskWarrior will display the task right away, and you want to
+showing up only during the weekend, so that it does not distract your task
+list during the work week.
+
+If you try to add the recurrence again, this time with ``wait`` attribute,
+to hide the task until it is not relevant for you:
+
+```
+$ task add due:sunday recur:weekly wait:saturday
+```
+
+You will find out that TaskWarrior does not let tasks generated by this
+recurrence inherit the ``wait`` attribute, in the same manner as it does
+with the ``due`` attribute.
+
+This hook solves that.
--- /dev/null
+#!/usr/bin/python
+
+import sys
+import os
+from tasklib import TaskWarrior
+
+time_attributes = ('wait', 'scheduled')
+
+def is_new_local_recurrence_child_task(task):
+ # Do not affect tasks not spun by recurrence
+ if not task['parent']:
+ return False
+
+ # Newly created recurrence tasks actually have
+ # modified field copied from the parent, thus
+ # older than entry field (until their ID is generated)
+ if (task['modified'] - task['entry']).total_seconds() < 0:
+ return True
+
+tw = TaskWarrior(data_location=os.path.dirname(os.path.dirname(sys.argv[0])))
+tw.overrides.update(dict(recurrence="no", hooks="no"))
+
+def hook_shift_recurrence(task):
+ if is_new_local_recurrence_child_task(task):
+ parent = tw.tasks.get(uuid=task['parent']['uuid'])
+ parent_due_shift = task['due'] - parent['due']
+ for attr in time_attributes:
+ if parent[attr]:
+ task[attr] = parent[attr] + parent_due_shift