File: taskadd

package info (click to toggle)
qutebrowser 3.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,432 kB
  • sloc: python: 72,411; javascript: 31,862; sh: 874; xml: 149; makefile: 52
file content (34 lines) | stat: -rwxr-xr-x 1,359 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash
#
# Behavior:
#   Userscript for qutebrowser which adds a task to taskwarrior.
#   If run as a command (:spawn --userscript taskadd), it creates a new task
#   with the description equal to the current page title and annotates it with
#   the current page url. Additional arguments are passed along so you can add
#   mods to the task (e.g. priority, due date, tags).
#
#   Example:
#       :spawn --userscript taskadd due:eod pri:H
#
#   To enable passing along extra args, I suggest using a mapping like:
#       :bind <somekey> cmd-set-text -s :spawn --userscript taskadd
#
#   If run from hint mode, it uses the selected hint text as the description
#   and the selected hint url as the annotation.
#
# Ryan Roden-Corrent (rcorre), 2016
# Any feedback is welcome!
#
# For more info on Taskwarrior, see https://taskwarrior.org/

# use either the current page title or the hint text as the task description
[[ $QUTE_MODE == 'hints' ]] && title=$QUTE_SELECTED_TEXT || title=$QUTE_TITLE

# try to add the task and grab the output
if msg="$(task add "$title" "$*" 2>&1)"; then
    # annotate the new task with the url, send the output back to the browser
    task +LATEST annotate "$QUTE_URL"
    echo "message-info '$(echo "$msg" | head -n 1)'" >> "$QUTE_FIFO"
else
    echo "message-error '$(echo "$msg" | head -n 1)'" >> "$QUTE_FIFO"
fi