#!/bin/bash # # Task list visualizer. # # Basic params CONFIG="$HOME/.config/todo" NAME="$0" BASENAME="`basename $NAME`" OPTION="$1" # Config if [ -e "$CONFIG" ] ; then source $CONFIG fi # Custom params TODO_MAXDEPTH="2" WORKPATH="${WORKPATH:=~/}" FOLDERS="`echo $WORKPATH | tr ':' ' ' | sed -e "s|~|$HOME|g"`" # Iterate function todo_find { for folder in $FOLDERS; do find $folder/ -maxdepth $TODO_MAXDEPTH -xtype f -iname 'todo*' | while read todo; do # Ignore lists without tasks if grep -q -e '*' -e '-' $todo; then echo $todo fi done done } function todo_list { todo_find | while read todo; do if [ "$todo" != "$NAME" ]; then path="`echo $todo | sed -e "s|^$HOME|~|"`" delim="===`echo $path | sed -e 's|.|=|g'`" echo "" echo In $path echo $delim echo "" grep -e '*' -e '-' $todo fi done } if [ "$OPTION" == "list" ]; then todo_find | grep -v -e "^$NAME$" | sed -e "s|^$HOME|~|" elif [ "$OPTION" == "count" ]; then todo_find | grep -v $NAME | wc -l elif [ "$OPTION" == "show" ]; then if [ ! -z "$2" ] && [ -e "$2" ]; then grep "TODO" $2 | sed -e 's/^ *//' fi elif [ "$OPTION" == "help" ]; then echo "usage: $BASENAME [list|count]" echo " $BASENAME show " else todo_list fi