blob: 1671485851b957ee3d723defed8122f5ce846a4f (
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
49
50
51
52
53
54
|
#!/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
else
todo_list
fi
|