]> git.madduck.net Git - etc/taskwarrior.git/blob - .zsh/zshrc/parts.d/50-taskwarrior

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

task postponement helper
[etc/taskwarrior.git] / .zsh / zshrc / parts.d / 50-taskwarrior
1 #
2 # taskwarrior shell integration
3 #
4 # Copyright © 2018 martin f. krafft <madduck@madduck.net>
5 # Released under the terms of the Artistic Licence 2.0
6 #
7 # Source repository: http://git.madduck.net/v/etc/zsh.git
8 #
9
10 if whence task >/dev/null; then
11
12   function task_() {
13     local spec cmd args nospec=0
14     cmd="$1"; shift
15     [[ "$cmd" = add ]] && nospec=1
16     for i in "$@"; do
17       case "$nospec@$i" in
18         (0@<->) :;&
19         (0@/*/) spec="${spec:+$spec }$i";;
20         (*) args="${args:+$args }$i";;
21       esac
22     done
23     eval task $spec $cmd $args
24   }
25
26   function task_postpone() {
27     local args
28     for i in scheduled due until wait; do
29       if [[ -n "$(eval task _get "$1"."$i")" ]]; then
30         args="${args:+$args }${i}:${i}+$2"
31       fi
32     done
33     eval task "$1" modify $args
34   }
35
36   alias t\?='alias -rm t t[-+a-z] | sed -r "s,_ ?, ,"'
37   alias ta='task_ add'
38   alias tc='task_ call'
39   alias th='task_ attach'
40   alias tl='task_ all'
41   alias ty='task_ next rc.recurrence=on >/dev/null && task_ sync'
42   alias td='task_ done'
43   alias te='task_ edit'
44   alias tu='task_ undo'
45   alias tm='task_ modify'
46   alias ts='task_ start'
47   alias tw='task_ waiting'
48   alias tp='task_postpone'
49   alias t+='task_ annotate'
50   alias t='task_ ""'
51
52   run_at_most_every 5m \
53     t 2>/dev/null || :
54 fi
55
56 # vim:ft=zsh