Skip to main content

Remind yourself to run Taskwarrior

After playing around with multiple techniques and programs for managing my todo tasks, I settled for Taskwarrior. I have been using Taskwarrior for a couple of months now, and I must say that it fits my requirements very nicely.

Initially, I was quite enthusiatic to play around with it, so I had no problem in actually remembering to run it every once in a while. But as it usually happens with todo managers and such, I actually started forgetting to run Taskwarrior to see what's on my list :P

This can be specially devastating if you happen to miss an important reminder, such as a bill payment reminder.

Force Taskwarrior to run every once in a while

To fix this problem, I decided to get Taskwarrior to run automatically, every once in a while. Since Taskwarrior is a command line based tool, I decided to leverage Bash's features to perform this task. Of course, you can use any shell of your choice to do the same.

So, I wrote a small bash script, which checks if Taskwarrior has been automatically run within the past day, and if it hasn't, then it runs it.

Here's the script:

#!/usr/bin/env bash

# Description
# ===========
# Run Taskwarrior once everyday upon running a shell.
#
# Requirements
# ============
# Taskwarrior: http://taskwarrior.org/
#
# Usage
# =====
# Use one of your shell initialization files, such as
# ~/.bash_profile or ~/.bashrc to run this script.

# Declarations
# ============
# directory to store the timestamp file
taskdir="$HOME/.local/share/taskreminder"

# task report to run
taskcommand="task long"

# timestamp format
datecmd=$(date +%Y%m%d)

# Main
# ====
# create timestamp file
mkdir -p "$taskdir"
cd "$taskdir"

# run taskwarrior if the timestamp file doesn't exist
if [[ ! -e lastrun ]]; then
    $taskcommand
    echo $(date +%Y%m%d) > lastrun
    exit
fi

# run taskwarrior if the current date is greater than the timestamp
if [[ $(cat lastrun) -lt "$datecmd" ]]; then
    $taskcommand
    echo $(date +%Y%m%d) > lastrun
    exit
fi

It's also available on GitHub: https://github.com/notfoss/utilities/blob/master/taskreminder.sh

I decided to run this script from my ~/.bash_profile, because I spawn terminals dozens of times everyday. You can probably use a cron job or such, to do the same. But, ~/.bash_profile suits my workflow. Of course, it will only run if it hasn't already, within the past day.

Conclusion

So, now that the problem of regularly viewing my todo list has been solved, my *productivity* will probably be on the incline. Let's hope that this problem isn't replaced with the problem of skimming through the list a bit too fast, or worse: the usual procrastination ;)