aboutsummaryrefslogtreecommitdiff
path: root/todo
blob: 3c17c4fd536ec8dd4941ff5fcaee94e2875e43fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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*'
  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 $delim
     echo In $path
     echo $delim
     echo ""
     cat $todo
    fi
  done
}

if [ "$OPTION" == "list" ]; then
  todo_list | less
else
  todo_find | grep -v -e "^$NAME$" | sed -e "s|^$HOME|~|"
fi