From 8b9cfd0456a1900300cc9f69d7e2f54635da69e0 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 15 Jun 2015 15:13:05 -0400 Subject: [PATCH] initial commit --- addp | 9 +++++++ addz | 6 +++++ can | 6 +++++ et | 6 +++++ hw | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lb | 29 +++++++++++++++++++++++ list | 1 + ls | 7 ++++++ noz | 6 +++++ pantop | 13 +++++++++++ rz | 9 +++++++ 11 files changed, 166 insertions(+) create mode 100755 addp create mode 100755 addz create mode 100755 can create mode 100755 et create mode 100755 hw create mode 100755 lb create mode 120000 list create mode 100755 ls create mode 100755 noz create mode 100755 pantop create mode 100755 rz diff --git a/addp b/addp new file mode 100755 index 0000000..529a8b3 --- /dev/null +++ b/addp @@ -0,0 +1,9 @@ +#!/bin/bash + +[ "$1" = "usage" ] && echo ' addz "THING I NEED TO DO +project @context"' && echo " add an item with z priority" && exit 0 +shift + +pri="$1" +shift + +"$TODO_FULL_SH" command add "($pri) $@" diff --git a/addz b/addz new file mode 100755 index 0000000..1b04712 --- /dev/null +++ b/addz @@ -0,0 +1,6 @@ +#!/bin/bash + +[ "$1" = "usage" ] && echo ' addz "THING I NEED TO DO +project @context"' && echo " add an item with z priority" && exit 0 +shift + +"$TODO_FULL_SH" command add '(Z) '"$@" diff --git a/can b/can new file mode 100755 index 0000000..550274d --- /dev/null +++ b/can @@ -0,0 +1,6 @@ +#!/bin/bash + +[ "$1" = "usage" ] && echo " can" && echo " List things with no \"req:\"" && exit 0 +shift + +"$TODO_FULL_SH" |grep -v "req:" diff --git a/et b/et new file mode 100755 index 0000000..fceb24a --- /dev/null +++ b/et @@ -0,0 +1,6 @@ +#!/bin/bash + +[ "$1" = "usage" ] && echo " et" && echo " Edit the todo.txt file with emacsclient -t" && exit 0 +shift + +emacsclient -t "$TODO_DIR/todo.txt" diff --git a/hw b/hw new file mode 100755 index 0000000..256f06d --- /dev/null +++ b/hw @@ -0,0 +1,74 @@ +#!/bin/bash + +me="$(basename $0)" + +textToDate () +{ + if [ ! "$(grep -P "(\d\d\.?){3}" <<< "$1")" ] + then + d=$(sed 's/^\(next\|n\)$/tomorrow/' <<< "$1") + date --date="$d" +"%Y-%m-%d" || exit 1 + else + echo "$1"; + fi +} + +if [ "$1" = "usage" ] +then + echo " hw" + echo " list homework" + echo " hw add" + echo " prompt for adding an assignment" + echo " hw [due date] [class] [description]" + echo " add an assignment without a prompt" + echo " hw [date]" + echo " list assignments due on [date]" + echo " hw rel" + echo " list assignments with the dates in days relative to today" + exit 0 +fi +shift + +if [ "$1" = "add" ] +then + read -p "Due: " due + due="$(textToDate "$date")" + read -p "Class: " class + read -p "Description: " desc + "$TODO_FULL_SH" add "(B) +hw" "class:$class $due $desc" +elif [ "$1" = "rel" ] +then + "$TODO_FULL_SH" "$me" | sed -e "s/.*/echo \'&\'/g;s/due:\([0-9-]*\)/due:\'"'$(( ($(date --date="\1" +%s) - $(date --date="00:00" +%s)) \/ 86400 ))'"\'d/ge" +elif [ -n "$1" -a -n "$2" -a -n "$3" ] +then + due="due:$(textToDate "$1")" || { echo "invalid date" ; exit 1; } + shift + class="class:$1" + shift + "$TODO_FULL_SH" add "(B) +hw $due $class $@" +else + IFS=$'\n' + today=$(textToDate "today" | tr -d '-') + if [ -n "$1" ] + then + inDate="$(textToDate "$1" | tr -d '-' | cut -f1)" + fi + x=0 + for i in $("$TODO_FULL_SH" list | grep "+hw") + do + x=$(($x+1)) + date=$(grep -oP "due:\K[0-9-]*" <<< "$i"| tr -d '-' | cut -f1) + if [ "$date" -le "$today" ] + then + echo "$i" | sed "s/\(due:[0-9-]*\)/$(tput bold)\1$(tput sgr0)/g" + elif [ -n "$inDate" ] + then + if [ "$date" -eq "$inDate" ] + then + echo "$i" + fi + else + echo "$i" + fi + done +fi diff --git a/lb b/lb new file mode 100755 index 0000000..b7ff476 --- /dev/null +++ b/lb @@ -0,0 +1,29 @@ +#!/bin/bash + +[ "$1" = "usage" ] && echo " lb proj|con" && echo " List by project or context" && exit 0 +shift + +type=$1 +first="true" +for i in $(todo.sh list$type) +do + #echo a newline before every $type, except the first + [ "$first" = "true" ] && first=0 || echo + + #color the header + if [ "$type" = "proj" ] + then + #this is a very nasty hack + echo -ne $(echo -ne "$COLOR_PROJECT") + elif [ "$type" = "con" ] + then + #still a nasty hack + echo -ne $(echo -ne "$COLOR_CONTEXT") + fi + echo "$i:" #the actual header + tput sgr0 #clear color + + "$TODO_FULL_SH" ls "$i" | + #remove todo.sh footer and indent lines + sed '/--/d;/TODO: [0-9]/d;s/^/ /g' +done diff --git a/list b/list new file mode 120000 index 0000000..3fbb950 --- /dev/null +++ b/list @@ -0,0 +1 @@ +ls \ No newline at end of file diff --git a/ls b/ls new file mode 100755 index 0000000..d077d36 --- /dev/null +++ b/ls @@ -0,0 +1,7 @@ +#!/bin/bash + +[ "$1" = "usage" ] && echo " ls" && echo " ls, highlighting 'req:'s" && exit 0 +shift + +echo -e "$("$TODO_FULL_SH" command ls $@ | + sed "s/\(req:[^ $]*\)/$RED\1$DEFAULT/g")" diff --git a/noz b/noz new file mode 100755 index 0000000..ed15e49 --- /dev/null +++ b/noz @@ -0,0 +1,6 @@ +#!/bin/bash + +[ "$1" = "usage" ] && echo " noz" && echo " ls without (Z) priority" && exit 0 +shift + +"$TODO_FULL_SH" listpri -z "$1" diff --git a/pantop b/pantop new file mode 100755 index 0000000..0ca8db6 --- /dev/null +++ b/pantop @@ -0,0 +1,13 @@ +#!/bin/bash + +[ "$1" = "usage" ] && exit 0 +shift + +text="$("$TODO_FULL_SH" -p ls | head -n1)" + +pri="PRI_$(sed -r 's/^[0-9]+ \(([A-Z])\).*/\1/' <<< "$text")" +text="${!pri}$text$DEFAULT" + +text="$(sed -r 's` (\+[^ $]*)` '"$COLOR_PROJECT"'\1'"$DEFAULT"'`' <<< "$text")" +text="$(sed -r 's` (@[^ $]*)` '"$COLOR_CONTEXT"'\1'"$DEFAULT"'`' <<< "$text")" +echo ''"$text"'' diff --git a/rz b/rz new file mode 100755 index 0000000..aef784e --- /dev/null +++ b/rz @@ -0,0 +1,9 @@ +#!/bin/bash + +[ "$1" = "usage" ] && echo " rz" && echo " get a random Z priority task" && exit 0 +shift + +number=$(( $RANDOM % ($("$TODO_FULL_SH" listpri Z "$1" | wc -l) -2) + 1 )) +#echo -n "$number " + +"$TODO_FULL_SH" listpri Z "$1" | sed $number'q;d'