aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Hovorka <[email protected]>2021-01-02 19:08:15 -0700
committerAlexis Hovorka <[email protected]>2021-01-02 19:08:15 -0700
commit0cb6fa7ea6dd6c6d17eb960e1a4a0cc9485ff29c (patch)
tree15aef185afecda8320aaced56198c425c705a43e
parentbd3d114f9513ddda9a2947ca1f6c995638c2006c (diff)
[feat] Add Taskwarrior aliases and custom reviewer
-rw-r--r--base.yaml1
-rw-r--r--base/task/main.rc34
-rwxr-xr-xbase/taskw227
-rw-r--r--base/zsh/aliases.zsh4
4 files changed, 241 insertions, 25 deletions
diff --git a/base.yaml b/base.yaml
index 48b11ec..859d3f6 100644
--- a/base.yaml
+++ b/base.yaml
@@ -18,6 +18,7 @@
~/.bin/pr-weasel: base/pr-weasel
~/.bin/proofread: base/proofread
~/.bin/qr: base/qr
+ ~/.bin/taskw: base/taskw
~/.bin/tldr: base/tldr
~/.capsesc: base/capsesc
~/.colorscheme: base/colorscheme
diff --git a/base/task/main.rc b/base/task/main.rc
index 18e1e0b..189425f 100644
--- a/base/task/main.rc
+++ b/base/task/main.rc
@@ -23,22 +23,6 @@ context.school=project:School
# MY THEME ====----
-# Color theme (uncomment one to use)
-#include /usr/share/doc/task/rc/light-16.theme
-#include /usr/share/doc/task/rc/light-256.theme
-#include /usr/share/doc/task/rc/dark-16.theme
-#include /usr/share/doc/task/rc/dark-256.theme
-#include /usr/share/doc/task/rc/dark-red-256.theme
-#include /usr/share/doc/task/rc/dark-green-256.theme
-#include /usr/share/doc/task/rc/dark-blue-256.theme
-#include /usr/share/doc/task/rc/dark-violets-256.theme
-#include /usr/share/doc/task/rc/dark-yellow-green.theme
-#include /usr/share/doc/task/rc/dark-gray-256.theme
-#include /usr/share/doc/task/rc/dark-gray-blue-256.theme
-#include /usr/share/doc/task/rc/solarized-dark-256.theme
-#include /usr/share/doc/task/rc/solarized-light-256.theme
-#include /usr/share/doc/task/rc/no-color.theme
-
rule.precedence.color=deleted,completed,active,keyword.,tag.,project.,overdue,scheduled,due.today,due,blocked,blocking,recurring,tagged,uda.
# General decoration
@@ -52,8 +36,8 @@ color.error=bold white on red
color.debug=color4
# Task state
-color.completed=
-color.deleted=
+color.completed=color8
+color.deleted=color8
color.active=bold color15 on color16
color.recurring=blue
color.scheduled=yellow
@@ -66,7 +50,7 @@ color.blocking=cyan
#color.project.none=
# Priority
-color.uda.priority.H=color7
+color.uda.priority.H=color15
color.uda.priority.L=color8
color.uda.priority.M=color20
@@ -109,8 +93,8 @@ color.sync.changed=yellow
color.sync.rejected=red
# Command: undo
-#color.undo.after=color2
-#color.undo.before=color1
+color.undo.after=color2
+color.undo.before=color1
# OTHER THINGS ====----
@@ -119,7 +103,7 @@ report.ready.labels=ID,Active,Age,P,Project,Tags,R,S,Due,Until,Description,Urg
uda.reviewed.type=date
uda.reviewed.label=Reviewed
-report._reviewed.description=Tasksh review report. Adjust the filter to your needs.
-report._reviewed.columns=uuid
-report._reviewed.sort=reviewed+,modified+
-report._reviewed.filter=( reviewed.none: or reviewed.before:now-6days ) and ( +PENDING or +WAITING )
+report._review.description=Show IDs of tasks to review
+report._review.columns=uuid
+report._review.sort=reviewed+,modified+
+report._review.filter=( reviewed.none: or reviewed.before:now-5days ) and ( +PENDING or +WAITING )
diff --git a/base/taskw b/base/taskw
new file mode 100755
index 0000000..66230cc
--- /dev/null
+++ b/base/taskw
@@ -0,0 +1,227 @@
+#!/bin/bash
+# Taskwarrior Wrapper
+
+if [[ ! "$TASKBIN" ]]; then
+ TASKBIN="task"
+fi
+
+DATEFMT="+%a %Y-%m-%d %H:%M"
+prettyage() {
+ AGE=$(date -d "$1" +%s)
+ NOW=$(date +%s)
+ DIF=$((NOW - AGE))
+ if ((DIF < 60)); then echo -n "${DIF}s"
+ elif ((DIF < 3600)); then echo -n "$((DIF / 60))m"
+ elif ((DIF < 86400)); then echo -n "$((DIF / 3600))h"
+ elif ((DIF < 1209600)); then echo -n "$((DIF / 86400))d"
+ elif ((DIF < 7776000)); then echo -n "$((DIF / 604800))w"
+ elif ((DIF < 31536000)); then echo -n "$((DIF / 2592000))m"
+ else echo -n "$((DIF / 31536000))y"; fi
+}
+
+function exitaltscreen {
+ clear
+ tput rmcup
+ exit 0
+}
+
+CMD="$1"
+shift
+
+case $CMD in
+ "")
+ TASKS="$($TASKBIN rc._forcecolor=yes rc.defaultwidth=$(tput cols) 2>&1 |
+ grep -v "mConfiguration override rc\.")"
+ if (( `tput lines` > `echo "$TASKS" | wc -l` )); then
+ echo "$TASKS"
+ else
+ echo "$TASKS" | less -R
+ fi
+ ;;
+
+ projects)
+ $TASKBIN rc.context= rc.list.all.projects=1 rc.verbose=blank,label projects $@
+ ;;
+
+ review) # <filter>
+ TASKS="$($TASKBIN rc.context= $@ _review | shuf)"
+ TASKCOUNT="$(echo "$TASKS" | wc -l)"
+ TASKNUMBER=1
+ LASTCMD=""
+ LASTRES=""
+
+ if [[ "$TASKCOUNT" = "1" ]]; then
+ echo "Nothing to review"
+ exit
+ fi
+
+ trap exitaltscreen SIGINT SIGTERM SIGQUIT
+ tput smcup
+
+ #for ID in $TASKS; do
+ while ((TASKNUMBER <= TASKCOUNT)); do
+ ID="$(echo "$TASKS" | head -n$TASKNUMBER | tail -n1)"
+
+ clear
+ for i in `seq $(( "$(tput lines)" / 2 - 8 ))`; do echo; done
+ echo -e "\e[38;5;19m$LASTRES"
+ echo -ne "\n\e[1;36;48;5;19m "
+ echo -ne "$TASKNUMBER/$TASKCOUNT "
+ TASKNUMBER=$((TASKNUMBER + 1))
+
+ PRIORITY="$($TASKBIN _get $ID.priority)"
+ if [[ "$PRIORITY" ]]; then
+ COLOR="0"
+ case $PRIORITY in
+ H) COLOR="1" ;;
+ M) COLOR="3" ;;
+ L) COLOR="8" ;;
+ esac
+ echo -ne "\e[0;38;5;19;48;5;${COLOR}m"
+ echo -ne "\e[0;38;5;${COLOR};48;5;18m"
+ echo -ne "\e[1;38;5;${COLOR}m $PRIORITY"
+ echo -ne "\e[0;48;5;18m "
+ else
+ echo -ne "\e[0;38;5;19;48;5;18m "
+ fi
+
+ AGE="$(prettyage "$($TASKBIN _get $ID.entry)")"
+ echo -ne "\e[37m$AGE "
+
+ #STATUS="$($TASKBIN _get $ID.status | tr -d "\n")"
+ #if [[ "$STATUS" != "pending" ]]; then echo -n "$STATUS "; fi
+
+ if [[ "$($TASKBIN _get $ID.start)" ]]; then
+ echo -ne "\e[0;38;5;18;48;5;16m\e[0;38;5;16m\e[0m "; else
+ echo -ne "\e[0;38;5;18m\e[0m "; fi
+ #$TASKBIN _get $ID.id | tr -d "\n"; echo -n ". "
+ $TASKBIN _get $ID.description | tr "\n" " "
+
+ echo -ne "\e[38;5;18m\e[0;48;5;18m "
+ TAGS="$($TASKBIN _get $ID.tags)"
+ PROJECT="$($TASKBIN _get $ID.project)"
+ if [[ "$TAGS" ]]; then
+ echo "$TAGS" | tr "," " " | while read TAG; do
+ if [[ "$TAG" = "next" ]]; then
+ echo -ne "\e[38;5;16m"; else
+ echo -ne "\e[38;5;17m"; fi
+ echo -ne "+$TAG "
+ done
+ fi
+ if [[ "$TAGS" && "$PROJECT" ]]; then
+ echo -ne "\e[30m "
+ fi
+ if [[ "$PROJECT" ]]; then
+ echo -ne "\e[38;5;20m$PROJECT"
+ fi
+
+ echo -e "\e[K\e[0m"
+ DUE="$($TASKBIN _get $ID.due)"
+ #RECUR="$($TASKBIN _get $ID.recur)" # TODO
+ SCHED="$($TASKBIN _get $ID.scheduled)"
+ UNTIL="$($TASKBIN _get $ID.until)"
+ WAIT="$($TASKBIN _get $ID.wait)"
+ if [[ "$DUE$SCHED$UNTIL$WAIT" ]]; then echo
+ if [[ "$DUE" ]]; then echo -e "\e[31m Due: $(date -d "$DUE" "$DATEFMT")\e[0m"; fi
+ #if [[ "$RECUR" ]]; then echo -e "\e[36mRecurring: $RECUR\e[0m"; fi
+ if [[ "$SCHED" ]]; then echo " Scheduled for: $(date -d "$SCHED" "$DATEFMT")"; fi
+ if [[ "$UNTIL" ]]; then echo " Valid until: $(date -d "$UNTIL" "$DATEFMT")"; fi
+ if [[ "$WAIT" ]]; then echo " Hidden until: $(date -d "$WAIT" "$DATEFMT")"; fi
+ fi
+
+ ANNOT=1
+ if [[ "$($TASKBIN _get $ID.annotations.$ANNOT.entry)" ]]; then
+ echo -e "\n \e[1;4;34mAnnotations\e[0m"; fi
+ while [[ "$($TASKBIN _get $ID.annotations.$ANNOT.entry)" ]]; do
+ echo -ne "\e[33m "
+ date -d "$($TASKBIN _get $ID.annotations.$ANNOT.entry)" "+%Y-%m-%d" | tr "\n" " "
+ echo -ne "\e[0m- "
+ $TASKBIN _get $ID.annotations.$ANNOT.description
+ ANNOT=$((ANNOT + 1))
+ done
+
+ DEPENDS="$($TASKBIN _get $ID.depends | tr "," "\n" | while read DID; do
+ if [[ "$DID" && "$($TASKBIN _get $DID.id)" != 0 ]]; then echo "$DID"; fi
+ done)"
+ if [[ "$DEPENDS" ]]; then
+ echo -e "\n \e[1;4;38;5;17mThis Depends On\e[0m"
+ echo "$DEPENDS" | while read DID; do
+ echo -n " - "
+ $TASKBIN _get $DID.description
+ done
+ fi
+
+ DEPENDENTS="$($TASKBIN depends:$ID _uuids)"
+ if [[ "$DEPENDENTS" ]]; then
+ echo -e "\n \e[1;4;32mTasks Depending On This\e[0m"
+ echo "$DEPENDENTS" | while read DID; do
+ echo -n " - "
+ $TASKBIN _get $DID.description
+ done
+ fi
+
+ NAGS="$(
+ if [[ ! "$PROJECT" ]]; then echo "Doesn't have a project!"; fi
+ )"
+ if [[ "$NAGS" ]]; then
+ echo -e "\e[0;1;31m"
+ echo "$NAGS" | sed "s/^/ /"
+ fi
+
+ echo -e "\n\e[0;90m (enter) next, (s)kip, (c)omplete, <modify...>"
+ echo " (d)elete, (e)dit, (n)ew task, (u)ndo, (q)uit"
+ echo -ne "\e[0;38;5;16m\e[0m "
+ read IN
+
+ case $IN in
+ "") $TASKBIN $ID modify reviewed:now &>/dev/null
+ LASTRES="Marked as reviewed." ;;
+ c) $TASKBIN $ID done &>/dev/null
+ LASTRES="Marked complete." ;;
+ d) $TASKBIN $ID delete &>/dev/null
+ LASTRES="Deleted." ;;
+ s) LASTRES="Skipped." ;;
+ e) $TASKBIN $ID edit
+ $TASKBIN $ID modify reviewed:now &>/dev/null
+ LASTRES="Edited." ;;
+
+ n) echo -ne "\n New Task:\n\e[0;38;5;16m\e[0m "
+ read NEWTASK
+ if [[ "$NEWTASK" ]]; then
+ $TASKBIN add $NEWTASK &>/dev/null
+ fi
+ TASKNUMBER=$((TASKNUMBER - 1))
+ LASTRES="Created: $NEWTASK" ;;
+
+ u) if [[ "$TASKNUMBER" = "2" ]]; then # Command running on #1
+ TASKNUMBER=$((TASKNUMBER - 1)) # Because it was already incremented
+ if echo "$LASTCMD" | grep -qi '^n$'; then
+ yes yes | task undo &>/dev/null
+ LASTRES="Reverted."
+ fi
+ else
+ if echo "$LASTCMD" | grep -qvi '^n$'; then
+ TASKNUMBER=$((TASKNUMBER - 2)); else
+ TASKNUMBER=$((TASKNUMBER - 1)); fi
+ if echo "$LASTCMD" | grep -qvi '^s$'; then
+ yes yes | task undo &>/dev/null
+ fi
+ LASTRES="Reverted."
+ fi ;;
+
+ q) exitaltscreen ;;
+ *) $TASKBIN $ID modify $IN reviewed:now &>/dev/null
+ LASTRES="Modified: $IN" ;;
+ esac
+
+ LASTCMD="$IN"
+ done
+
+ # TODO triggers for new tasks
+ exitaltscreen
+ ;;
+
+ *)
+ task $CMD $@
+ ;;
+esac
diff --git a/base/zsh/aliases.zsh b/base/zsh/aliases.zsh
index 3c65362..9613304 100644
--- a/base/zsh/aliases.zsh
+++ b/base/zsh/aliases.zsh
@@ -47,4 +47,8 @@ alias reboot="systemctl reboot"
alias shutdown="systemctl poweroff"
alias poweroff="systemctl poweroff"
+# TASKWARRIOR
+export TASKBIN="$(builtin which task)"
+alias task="taskw"
+
alias whoaminot="echo adam"