From 6ce3ad68f8c5cdbaf8c5b8224ae84871cf8587e1 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Sat, 4 Jun 2016 06:45:05 -0400 Subject: [PATCH 1/3] Add a userscript to integrate with taskwarrior. The `taskadd` userscript adds a task based on the current title and URL. It passes additional arguments along to `task`. For example: :spawn --userscript taskadd due:eod pri:H will add a task with high priority due at the end of the day. The description will be the current page title and it will be annotated with the current page url. If used with hints, the hint text is used as the description. Unfortunately, there is currently no way to use :hint fill and maintain the hint text, which limits the ability to provide additional args in hint mode. --- misc/userscripts/taskadd | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 misc/userscripts/taskadd diff --git a/misc/userscripts/taskadd b/misc/userscripts/taskadd new file mode 100755 index 000000000..99f2a35b7 --- /dev/null +++ b/misc/userscripts/taskadd @@ -0,0 +1,39 @@ +#!/bin/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 set-cmd-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 http://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 +msg="$(task add $title $@ 2>&1)" + +if [[ $? == 0 ]]; then + # scan the output for the new task number + num=$(echo $msg | sed -r 's/Created task ([0-9]+)\./\1/') + + # annotate the new task with the url, send the output back to the browser + task $num annotate "$QUTE_URL" + echo "message-info '$msg'" >> $QUTE_FIFO +else + echo "message-error '$msg'" >> $QUTE_FIFO +fi From 06adfc5bff029e1c69a11ba9fb15c18e2dbfd808 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Wed, 6 Jul 2016 08:04:06 -0400 Subject: [PATCH 2/3] Leverage +LATEST in taskadd userscript. This is cleaner than parsing the output of `task`. --- misc/userscripts/taskadd | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/misc/userscripts/taskadd b/misc/userscripts/taskadd index 99f2a35b7..a60dbcdd7 100755 --- a/misc/userscripts/taskadd +++ b/misc/userscripts/taskadd @@ -28,11 +28,8 @@ msg="$(task add $title $@ 2>&1)" if [[ $? == 0 ]]; then - # scan the output for the new task number - num=$(echo $msg | sed -r 's/Created task ([0-9]+)\./\1/') - # annotate the new task with the url, send the output back to the browser - task $num annotate "$QUTE_URL" + task +LATEST annotate "$QUTE_URL" echo "message-info '$msg'" >> $QUTE_FIFO else echo "message-error '$msg'" >> $QUTE_FIFO From 31b4f2e3831d6ca1f8d6580ae65492fb40e3da87 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 11 Jul 2016 21:15:03 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.asciidoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index a0098b8f9..e2efcfe05 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -36,6 +36,8 @@ Changed - `:edit-url` now does nothing if the URL isn't changed in the spawned editor. - `:bookmark-add` can now be passed a URL and title to add that as a bookmark rather than the current page. +- New `taskadd` userscript to add a taskwarrior task annotated with the + current URL. Removed -------