]> gitweb.fluxo.info Git - scripts.git/commitdiff
Adds task list visualizer
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 13 Oct 2016 16:56:42 +0000 (13:56 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 13 Oct 2016 16:56:42 +0000 (13:56 -0300)
todo [new file with mode: 0755]

diff --git a/todo b/todo
new file mode 100755 (executable)
index 0000000..f5ff50f
--- /dev/null
+++ b/todo
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# Task list visualizer.
+#
+
+# Basic params
+CONFIG="$HOME/.config/todo"
+BASENAME="`basename $0`"
+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 -iname 'todo*'
+  done
+}
+
+function todo_list {
+  todo_find | while read line; do
+    path="`echo $line | sed -e "s|^$HOME|~|"`"
+    delim="====`echo $path | sed -e 's|.|=|g'`"
+    echo ""
+    echo $delim
+    echo In $path:
+    echo $delim
+    echo ""
+    cat $line
+  done
+}
+
+if [ "$OPTION" == "list" ]; then
+  todo_list | less
+else
+  todo_find | sed -e "s|^$HOME|~|"
+fi