#! /bin/sh # # Mon May 10 10:39:28 2006 # Copyright 2006 Pierre # pierre-at-coldev-dot-org # # Heavily based on Gina Trapani's work # http://www.ginatrapani.org/ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # if [ ! -d ~/ptdl ]; then mkdir ~/ptdl fi if [ ! -f ~/ptdl/todo.txt ]; then touch ~/ptdl/todo.txt fi if [ ! -f ~/ptdl/done.txt ]; then touch ~/ptdl/done.txt fi if [ "$#" -eq 0 ]; then cat -n ~/ptdl/todo.txt | sort -k2,5 else if [ "$1" = "l" ]; then if [ "$#" -ne 2 ]; then # insufficient number of params echo "Usage: $0 $1 FILTER" exit 1 fi cat -n ~/ptdl/todo.txt | grep "$2" | sort -k2,5 fi if [ "$1" = "a" ]; then if [ "$#" -lt 4 ]; then # insufficient number of params echo "Usage: $0 $1 C:category T:task L:location [L:other locations]" exit 1 fi echo "$*" | cut -d ' ' -f 2- >> ~/ptdl/todo.txt echo "Task '$3' added to the list !" fi if [ "$1" = "p" ]; then if [ "$#" -ne 3 ]; then # insufficient number of params echo "Usage: $0 $1 linenumber priority" exit 1 fi sed $2"s/^/($3) /" ~/ptdl/todo.txt > /dev/null 2>&1 if [ "$?" -eq 0 ]; then # it's all good, continue sed $2"s/^/($3) /" ~/ptdl/todo.txt > ~/ptdl/todo.tmp mv ~/ptdl/todo.tmp ~/ptdl/todo.txt echo "Marked $2 as priority $3 !" else echo "usage: $0 $1 linenumber priority" exit 1 fi fi if [ "$1" = "d" ]; then if [ "$#" -ne 2 ]; then # insufficient number of params echo "Usage: $0 $1 linenumber" exit 1 fi sed $2's/^/x /' ~/ptdl/todo.txt > ~/ptdl/todo.tmp mv ~/ptdl/todo.tmp ~/ptdl/todo.txt echo "Marked $2 as done !" fi if [ "$1" = "A" ]; then grep ^x ~/ptdl/todo.txt >> ~/ptdl/done.txt sed -e '/^x/d' ~/ptdl/todo.txt > ~/ptdl/todowithoutdone.tmp mv ~/ptdl/todowithoutdone.tmp ~/ptdl/todo.txt echo "Moved all done tasks to done.txt !" fi if [ "$1" = "r" ]; then "$0" A echo $(date +%Y-%m-%d) >> ~/ptdl/report.tmp echo ' ' >> ~/ptdl/report.tmp wc -l ~/ptdl/todo.txt >> ~/ptdl/report.tmp echo ' ' >> ~/ptdl/report.tmp wc -l ~/ptdl/done.txt >> ~/ptdl/report.tmp tr -d '\r\n' < ~/ptdl/report.tmp >> ~/ptdl/report.txt echo '' >> ~/ptdl/report.txt rm ~/ptdl/report.tmp cat ~/ptdl/report.txt fi if [ "$1" = "help" ]; then echo "Usage $0 [MODE] [PARAMS]" echo "Modes can be :" echo "l: filter tasks list" echo "a: add a new task" echo "A: archive done tasks" echo "d: mark a task as done" echo "p: change a task's priority" echo "r: archive and display a report" fi fi