-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhabit-editor
executable file
·58 lines (45 loc) · 917 Bytes
/
habit-editor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
#
# Add a task to Taskwarrior ('habit' context) via vim (yaml).
export TASKRC=$XDG_CONFIG_HOME/taskwarrior/taskrc-habit
eval "$(exec date '+s=%s d=%Y-%m-%d t=%H:%M')"
f=${TMPDIR:-${XDG_RUNTIME_DIR}/tmp}/$s.task
trap 'exec rm -- "$f"' EXIT
command -- cat >"$f" <<TEMPLATE
%YAML 1.1
---
description:
# role: me
# opposite: me
# contact: face-to-face
# location: somewhere
# participant: me
entry: now
# due: ${d}_00:00
# scheduled: ${d}_00:00
# wait: ${d}_00:00
# until: ${d}_00:00
# recur:
# depends:
# -
# project:
# priority:
tags:
- habit
- deletable
# annotations:
# -
# entry: now
# description:
...
TEMPLATE
command -- vim -f \
'+set ft=yaml' \
+3 \
'+startinsert!' \
"$f" </dev/tty >/dev/tty ||
exit 1
exec yaml2json <"$f" |
exec jq 'if (.description | length) > 0 then . else empty end' |
exec task import -
# vim: set ft=sh :