summaryrefslogtreecommitdiff
path: root/examples/task-management-examples
blob: 4bdc70833dbfbea8956d9a568f70847d6e6210cd (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
## This was my daily task management workflow for a while.

## Eventually I'd like to make calendar-cli easier to use, so some of the "external logic" in those examples will eventually be moved into the tool itself.  Anyway, some of the power of having a command-line utility is that it's possible to do just anything ...

[ -z "$EDITOR" ] && EDITOR=vi

echo "Enter a category or enter for all:"
read category
if [ -n "$category" ]
then
    selflags="--categories=$category"
fi

## Take out a personal agenda from different calendar sources:

echo "Here is your upcoming calendar events:"
for section in pir seb house default work holidays
do
    calendar-cli --config-section $section calendar agenda  --agenda-days 20
done | sort

echo -e "\nAnd here is your upcoming calendar tasks:"
for section in seb house default work-tasks pir-tasks
do 
    echo $section
    calendar-cli --config-section $section todo $selflags --limit 10 --hide-parent list
done


## Interactively set categories on uncategorized tasks:
tempfile=$(mktemp)
calendar-cli todo --nocategories list --todo-template='calendar-cli todo --todo-uid={uid} edit --set-categories=foo # {summary}' > $tempfile
if [ -s $tempfile ]
then
    ## We have non-categorized tasks
    echo -e "\nNext up: categorization of uncategorized tasks.  Press enter"
    read
    tempfile2=$(mktemp)
    ## Populate the tempfile with the list of categories first
    calendar-cli todo list --list-categories | perl -pe 's/^/# /' > $tempfile2
    cat $tempfile >> $tempfile2
    while grep -q -- '--set-categories=foo ' $tempfile2
    do
        $EDITOR $tempfile2
    done
    . $tempfile2
    rm $tempfile2
else
    echo "No uncategorized todo-items on the calendar.  Good!"
fi


## Interactively mark tasks as completed:
calendar-cli todo $selflags --hide-parents --limit 12 list --todo-template='# calendar-cli todo --todo-uid={uid} complete # {summary}' > $tempfile
## Exit if there aren't any tasks
if [ ! -s $tempfile ]
then
    echo "No tasks available.  Good?"
    exit 0
fi

echo -e "\nNext up: Mark tasks that are completed as completed.  Press enter"
read
$EDITOR $tempfile
. $tempfile

## Set more realistic due-dates on overdue tasks
calendar-cli todo --overdue list --todo-template='calendar-cli todo --todo-uid={uid} postpone --due "in 15d" # {summary}' > $tempfile 
if [ -s $tempfile ]
then
    echo -e "\nNext up: Look over overdue tasks and consider procrastinating some of them.  Press enter"
    read
    $EDITOR $tempfile
    . $tempfile
fi

## Clean the list a bit by procrastinating tasks (this includes the overdue)
calendar-cli todo --limit 10 --hide-future list --todo-template='calendar-cli todo --todo-uid={uid} postpone "in 4d" # {summary}' > $tempfile
if [ -s $tempfile ]
then
    echo -e "\nNext up: Consider procrastinating the start-date of some of the tasks on your list.  Press enter"
    read
    $EDITOR $tempfile
    . $tempfile
fi

## Simple sync of a google calendar into personal calendar
wget -O- https://www.google.com/calendar/ical/gsmk.gcal%40gmail.com/public/basic.ics | calendar-cli calendar addics


echo "Done!"