forked from markwu/todo-cli-plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lately
executable file
·35 lines (28 loc) · 832 Bytes
/
lately
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
#!/bin/bash
DEFAULT=7
action=$1
days=$2
if [ -z $2 ]; then
days=$DEFAULT
[ -z $TODOTXT_LATELY_DEFAULT ] || days=$TODOTXT_LATELY_DEFAULT
fi
TMP_FILE=/tmp/lately.txt
CUTOFF=$(date --date="$days days ago" +%F)
if [ $? != 0 ]; then echo Usage:; action="usage"; fi
CUTOFF=$(date --date="$CUTOFF" +%s)
[ -e $TMP_FILE ] && rm $TMP_FILE
[ "$action" = "usage" ] && {
echo " lately [days]"
echo " generates a list of completed tasks during the last $DEFAULT days."
echo " Optional argument (integer) overrides number of days."
echo ""
exit 0
}
while read line; do
ll=($line)
ll=${ll[1]}
ll=$(date --date="$ll" +%s)
[ $ll -lt $CUTOFF ] || echo $line >> $TMP_FILE
done < $TODO_DIR/done.txt
if [ ! -e $TMP_FILE ]; then echo "No completed tasks in the past $days day(s)."; exit 0; fi
$TODO_FULL_SH -p lf $TMP_FILE