aboutsummaryrefslogtreecommitdiff
path: root/todo
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-08-20 20:42:35 -0300
committerSilvio Rhatto <rhatto@riseup.net>2024-08-20 20:42:35 -0300
commit3c5c672e47737e6b3342dfeb730ccd8320f2d442 (patch)
treed08d27539f244e640cf1e92ed0f259929fdf5d32 /todo
downloadutils-organization-3c5c672e47737e6b3342dfeb730ccd8320f2d442.tar.gz
utils-organization-3c5c672e47737e6b3342dfeb730ccd8320f2d442.tar.bz2
Initial import
Diffstat (limited to 'todo')
-rwxr-xr-xtodo120
1 files changed, 120 insertions, 0 deletions
diff --git a/todo b/todo
new file mode 100755
index 0000000..c51d295
--- /dev/null
+++ b/todo
@@ -0,0 +1,120 @@
+#!/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
+ if [ ! -d "$folder" ]; then
+ continue
+ fi
+
+ 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 {
+ local status="$1"
+
+ # User's Taskwarrior
+ if which task &> /dev/null; then
+ if [ "`task status:pending count 2> /dev/null`" != "0" ]; then
+ echo "taskwarrior:"
+ #echo ""
+ task list 2> /dev/null
+ echo ""
+ fi
+
+ # Taskwarrior data from projects
+ if [ ! -z "$status" ]; then
+ taskstatus="+$status"
+ SILENT="true"
+ fi
+
+ SILENT=$SILENT tasks $taskstatus list 2> /dev/null
+ echo ""
+ fi
+
+ # User's Timewarrior
+ if which timew &> /dev/null; then
+ if ! timew | grep -q "^There is no active time tracking."; then
+ timew
+ echo ""
+ fi
+ fi
+
+ todo_find | while read todo; do
+ if [ "$todo" != "$NAME" ]; then
+ if [ ! -z "$status" ] && ! grep -q "\($status\)" $todo; then
+ continue
+ fi
+
+ path="`echo $todo | sed -e "s|^$HOME|~|"`"
+ delim="===`echo $path | sed -e 's|.|=|g'`"
+ #echo ""
+ echo In $path
+ echo $delim
+ echo ""
+
+ if [ ! -z "$status" ]; then
+ if echo $todo | grep -q $status; then
+ grep -e '\* \[ \]' -e '-' $todo
+ else
+ grep -e '\* \[ \]' -e '-' $todo | grep "\($status\)"
+ fi
+ else
+ grep -e '\* \[ \]' -e '-' $todo
+ fi
+
+ echo ""
+ fi
+ done
+}
+
+if [ "$OPTION" == "find" ]; 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" ] || [ "$OPTION" == "see" ] || [ "$OPTION" == "view" ]; then
+ if [ ! -z "$2" ] && [ -e "$2" ]; then
+ # Check TODO inside files
+ grep -i "todo" $2 | sed -e 's/^ *//'
+
+ # Check also for FIXMEs
+ fixmes $2
+ elif cd $2 &> /dev/null; then
+ (
+ cd $2 &> /dev/null
+ find -maxdepth 1 -xtype f -iname 'todo*' -exec cat {} \; | grep -e '*' -e '-'
+ )
+ fi
+elif [ "$OPTION" == "list" ]; then
+ todo_list $2
+elif [ "$OPTION" == "help" ]; then
+ echo "usage: $BASENAME [list|count]"
+ echo " $BASENAME <show|see|view> <file|project>"
+else
+ todo_list
+fi