-
Notifications
You must be signed in to change notification settings - Fork 0
/
tn
executable file
·88 lines (75 loc) · 2.53 KB
/
tn
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
###############################################################################
# tasknote - associate note file with individual tasks in taskwarrior
# http://taskwarrior.org/projects/1/wiki/Tasknote
#
# Copyright 2011, Alan Bowen, [email protected].
# All rights reserved.
#
# based on taskopen - file based notes with taskwarrior
#
# Copyright 2010, Johannes Schlatow.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the
#
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA
# 02110-1301
# USA
#
###############################################################################
EDITOR=sensible-editor
TASKBIN=task
# If you sync tasks FOLDER should be a location that syncs and is available to
# other computers, i.e. /users/dropbox/tasknotes
# FOLDER to store notes in, must already exist!
# FOLDER="/users/dropbox/taskwarrior/tasknotes/"
# -for local mahern
FOLDER="${HOME}/Dropbox/.task/notes/"
# Preferred extension for tasknotes
EXT=".txt"
# Message that gets annotated to the task to indicate that notes exist
# -for local
NOTEMSG="Notes TN"
# Display usage if task number not supplied on cli
if [ $# != 1 ]; then
echo "TaskNote 2.x Usage: $0 <id>"
exit 1
fi
# Find UUID from given task
uuid=$($TASKBIN rc._forcecolor=no rc.defaultwidth=300 $* information | grep UUID | grep -o "[-a-f0-9]*\$")
# build full path & file name to store notes in
file="$FOLDER$uuid$EXT"
# determine if notes file already exists
fileexists=0
if [ -f $file ]; then
fileexists=1
else
head=$($TASKBIN all | head -n 2 | tail -n 1)
text=$($TASKBIN all | grep ^$*)
echo "# ${head}" > $file
echo "# ${text}" >> $file
echo "[----------------------------------------------------------------------]" >> $file
fi
#create/edit $file with editor
$SHELL -c "$EDITOR $file"
# if note was just created, add NOTEMSG as annotation to task
if [ $fileexists = 0 ]; then
if [ -f $file ]; then
$SHELL -c "$TASKBIN $* annotate $NOTEMSG"
fi
fi
exit 0