-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patht
More file actions
executable file
·117 lines (101 loc) · 3.93 KB
/
t
File metadata and controls
executable file
·117 lines (101 loc) · 3.93 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# Move focus back to current window when opening URLs
preserve_focus=true
# default_filter="-ignore"
default_filter=$(grep -E '^report.ls.filter=' ~/.taskrc | cut -d = -f 2-)
filter_new="+u or +n"
# filter_doing="+d"
web_browser_command="xdg-open"
web_browser_command="google-chrome --profile-directory=Default"
usage(){
cat << EOF
TaskWarrior scripts
If command is not existing, just call task with the same arguments
Usage:
t command args
t taskwarriorarguments
commands:
w TASKS Tag as Waiting
q TASKS Tag as Queued
d TASKS Tag as Doing
a TASK ANNOTATION Annotate a task
sa TASK Show annotations for task
o TASK Open task URL
i TASK Tag as ignore
ns TASK Tag as noshow
wo TASK Open and tag as waiting
rmlock Remove bugwarrior lock file
h This help
you can use a tag filter as args, example:
t o +u Open all the tasks that are tagged +u (updated)
Examples:
t w 20
t w "/text that matches task/"
t d 15 30
t next
My tags:
w Waiting - waiting for feedback or other external events
q Queued - ready to pick up and start working
d Doing - in progress
n New - New imported task. To be revised and moved in one of the previous states
u Updated - Updated imported task. To be revised and moved in one of the previous states
noshow - Do not show in list until task is updated again
ignore - Do not show in list EVER
EOF
exit 1
}
# Save current window_id
if [ "$preserve_focus" == "true" ]; then
if command -v xdotool > /dev/null; then
window=$(xdotool getwindowfocus)
else
preserve_focus=false
fi
fi
# Open URLs in browser preserving focus on current window
open_url(){
task info "$1" |awk '/^[A-Z][a-z]+ URL/{print $3}' | xargs -r $web_browser_command > /dev/null 2>&1
if [ "$preserve_focus" == "true" ]; then
declare -i n=0
# Wait until focus jumps to another window or until timeout of 3 seconds
until xdotool getwindowfocus | grep -qvx "$window"; do
sleep 0.1
n=$((n+1))
[ $n -gt 30 ] && break
done
# Set window focus back
xdotool windowfocus "$window"
fi
}
get_ids(){
local default_action_filter tmp_var
default_action_filter=$filter_new
[[ "$1" == "--filter" ]] && { tmp_var=filter_$2; default_action_filter=${!tmp_var}; shift 2; }
first=${1:-$default_action_filter}
if echo "$first" | grep -qE '^[\+-]'; then
task _uuid "($first) and ($default_filter)"
else
echo "$*"
fi
}
get_annotations(){
# This is very dirty ....
(
echo "# $(task _get $1.description)"
task info "$1" | sed -n '/^Description/,/^Status/{//!p}'| cut -c 15- | perl -0pe 's/\n(?!( ))/ /g' | cut -d ' ' -f 5-
) | bat --language=md --plain
}
case $1 in
rmlock) rm -f $HOME/.task/lockedtask /home/javipolo/.task/bugwarrior.lockfile;;
ns) shift; for id in $(get_ids "$@"); do echo all | task "$id" mod +noshow; done ;;
i) shift; for id in $(get_ids "$@"); do echo all | task "$id" mod +ignore; done ;;
w) shift; for id in $(get_ids "$@"); do echo all | task "$id" mod -n -u +w -q -d -next -noshow; done ;;
q) shift; for id in $(get_ids "$@"); do echo all | task "$id" mod -n -u -w +q -d -next -noshow; done ;;
d) shift; for id in $(get_ids "$@"); do echo all | task "$id" mod -n -u -w -q +d -next -noshow; done ;;
wo) shift; for id in $(get_ids "$@"); do open_url "$id"; task "$id" mod -n -u +w -q -d -next -noshow; done ;;
o) shift; for id in $(get_ids "$@"); do open_url "$id"; done ;;
a) shift; task annotate "$@" ;;
sa) shift; for id in $(get_ids --filter doing "$@"); do get_annotations "$id"; done ;;
h|help) usage ;;
*) task "$@" ;;
esac