From b2bea6a2530dc8ae41eb5120565406fb7317e3b5 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Thu, 31 Jan 2019 12:32:06 +1300 Subject: [PATCH 1/1] add support for attaching/calling extdata --- .bin/task_attach | 41 ++++++++++++++++++++++++++++++ .bin/task_call | 42 +++++++++++++++++++++++++++++++ .config/taskwarrior/rc | 10 ++++++++ .gitignore.d/taskwarrior | 2 ++ .zsh/zshrc/parts.d/50-taskwarrior | 2 ++ 5 files changed, 97 insertions(+) create mode 100755 .bin/task_attach create mode 100755 .bin/task_call diff --git a/.bin/task_attach b/.bin/task_attach new file mode 100755 index 0000000..efcbf4b --- /dev/null +++ b/.bin/task_attach @@ -0,0 +1,41 @@ +#!/bin/sh +set -eu + +if [ $# != 2 ]; then + echo >&2 E: Need exactly two arguments. + return 1 +fi + +TSK="$1" +LINK="$2" + +case "$LINK" in + (*@*|"<*>") + LINK="${LINK%>}"; LINK="%{LINK#<}" + echo >&2 I: "Adding MsgID <$LINK> to task $TSK" + task "$TSK" mod data:msgid:"$LINK" + ;; + + (*://*) + echo >&2 I: "Adding URL $LINK to task $TSK" + task "$TSK" mod data:url:"$LINK" + ;; + + (*) + if [ -f "$LINK" ]; then + + LINK="$(readlink -e "$LINK")" + + case "$LINK" in + ($HOME/*) LINK="~${LINK#$HOME}";; + esac + echo >&2 I: "Adding file $LINK to task $TSK" + task "$TSK" mod data:file:"$LINK" + + else + echo >&2 E: "Don't know how to handle link data $LINK" + return 1 + + fi + ;; +esac diff --git a/.bin/task_call b/.bin/task_call new file mode 100755 index 0000000..9f43a67 --- /dev/null +++ b/.bin/task_call @@ -0,0 +1,42 @@ +#!/bin/sh +set -eu + +if [ $# != 1 ]; then + echo >&2 E: Need exactly one argument. + return 1 +fi + +TSK="$1" + +DATA="$(task _get "$TSK".data)" +DATATYPE="${DATA%%:*}" +DATAPAYL="${DATA#*:}" + +case "$DATATYPE" in + ('') + echo >&2 I: No link data available for this task. + task "$TSK" + ;; + + (msgid) + mutt -f =store -e "push '~i $DATAPAYL'" + ;; + + (url) + sensible-browser "$DATAPAYL" + ;; + + (file) + if eval test -f "$DATAPAYL"; then + case "$(file --mime-type "$DATAPAYL")" in + (*": text/"*) eval sensible-editor "$DATAPAYL";; + (*) eval run-mailcap --action=edit "$DATAPAYL";; + esac + fi + ;; + + (*) + eval run-mailcap --action=edit "$DATAPAYL" + ;; + +esac diff --git a/.config/taskwarrior/rc b/.config/taskwarrior/rc index 174ed85..0d33a22 100644 --- a/.config/taskwarrior/rc +++ b/.config/taskwarrior/rc @@ -8,3 +8,13 @@ include /usr/share/taskwarrior/holidays.de-DE.rc include /usr/share/taskwarrior/holidays.en-NZ.rc include ~/.config/taskwarrior/taskd-credentials.rc + +uda.data.type=string +uda.data.label=Ext.data +uda.data.indicator=→ + +report.next.columns=id,data.indicator,start.age,entry.age,depends,priority,project,tags,recur,scheduled.countdown,due.relative,until.remaining,description,urgency +report.next.labels=ID,X,Active,Age,Deps,P,Project,Tag,Recur,S,Due,Until,Description,Urg + +alias.call=execute task_call +alias.attach=execute task_attach diff --git a/.gitignore.d/taskwarrior b/.gitignore.d/taskwarrior index 9e0a8b6..821a050 100644 --- a/.gitignore.d/taskwarrior +++ b/.gitignore.d/taskwarrior @@ -1,4 +1,6 @@ * +!/.bin/task_attach +!/.bin/task_call !/.config/taskwarrior/.gitignore !/.config/taskwarrior/rc !/.crontab.d/taskwarrior diff --git a/.zsh/zshrc/parts.d/50-taskwarrior b/.zsh/zshrc/parts.d/50-taskwarrior index 561493a..9138c2b 100644 --- a/.zsh/zshrc/parts.d/50-taskwarrior +++ b/.zsh/zshrc/parts.d/50-taskwarrior @@ -12,6 +12,8 @@ if whence task >/dev/null; then alias t=task alias t\?='alias -rm t t[a-z]' alias ta='t add' + alias tc='t call' + alias th='t attach' alias tn='t next' alias tl='t all' alias ty='t sync' -- 2.39.5