-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathletsdo-taskwarrior-task.sh
executable file
·51 lines (44 loc) · 1.71 KB
/
letsdo-taskwarrior-task.sh
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
#!/usr/bin/env bash
# -*- coding: UTF-8 -*-
#set -x
# description is a task description in the form of "<some random description> [hash]"
# if [hash] is present, this script is expected to look for a corresponding task and start
# a letsdo activity using its description and project. Otherwise, it will start a
# letsdo activity with the original input description
description=$*
# default cmd uses input description for letsdo
cmd="lets goto $description"
# Use a regular expression to extract the hash (UUID)
hash=$(echo "$description" | grep -oE '[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}|[a-f0-9]{8}')
for ctx in "wk" "me"; do
TASK="task"
if [ "$ctx" = "wk" ]; then
TASK="task rc:~/.taskworkrc"
fi
if [ -n "$hash" ]; then
task_description=$($TASK "$hash" export | jq -r '.[0].description')
if [ -z "$task_description" ] || [ "$task_description" = "null" ]; then
continue
fi
project=$($TASK "$hash" export | jq -r '.[0].project')
if [ "$project" != "null" ]; then
PROJECT="@$project"
fi
if tw_tags=$($TASK "$hash" export | jq -r '.[0].tags'); then
if [ -n "$tw_tags" ] && [ "$tw_tags" != "null" ]; then
tw_tags=$($TASK "$hash" export | jq -r '.[0].tags[]')
ld_tags=""
for tw_tag in ${tw_tags}; do
if [ "$tw_tags" == "meeting" ]; then
continue
fi
ld_tags+="#$tw_tag "
done
fi
fi
lets goto "$task_description" "$PROJECT" "$ld_tags" +"$ctx"
exit $?
fi
done
# no taskwarrior task found, start a letsdo session with the input description
$cmd