OFFERINGS

by Steve Dondley

Setting Up Multiple Project Areas with Taskwarrior

   Updated:

Preface

Taskwarrior (TW) is an open source task management platform built for those who prefer to work on the command line. Like most command line tools with any sophistication, it has a learning curve that, at first, requires a fairly significant investment of time in order take advantage of its best features. But like any serious tool, once mastered, your time invested will pay off in spades with much increased efficiency and much less agony dealing with a GUI that slows you down and makes you want to scratch your eyeballs out.

The Problem

Out of the box, TW dumps all of your projects into one list. Yes, there are ways you can filter these lists. But there are cases where you may want to have a separate project area dedicated to certain types of projects. For example, you may have one task list that you share with others and another that you’d prefer to keep private.

The Solution: Multiple .taskrc Files and .task Directories

As outlined in man taskd, TW provides a mechanism for overriding which .taskrc file is used. By default, TW uses ~/.taskrc. This is the file, like other “rc” files, that you can use to change the behavior of your application. So modifying the configuration settings in ~/.taskrc will change how TW behaves. Among other things, the .taskrc file controls which ~/.task directory is used to store data about your tasks and this is the key mechanism we use to switch between project areas. The other bit of magic needed to make this happen is setting a simple environment variable to tell TW which .taskrc file to load.

Follow the steps below to take to modify this file and directory to segregate your tasks into different project areas. For the purposes of this tutorial, we will set up a “work” project area for tasks related to pleasing your bosses (or pissing them off, if you are so inclined), and a “personal” project area for holding your life together and hopefully making a more pleasurable one for yourself.

Step 1: Copy the .taskrc file

cd ~
cp .taskrc .taskrc_work

This is the .taskrc we will use for our work tasks. For simplicity’s sake, we will leave the default rc file name unchanged and use it for our personal tasks.

Step 2: Copy the .task directory

cp -r .task .task_work

Now we have a new home for storing our work tasks.

Step 3: Edit the ~/.taskrc_work file

Step 3a: Modify the data.location setting

Look for the data.location key and change its value to ~/.task_work

Here we tell our rc file to used the directory we created in step 2 for our tasks.

Step 3b: Change the color theme

Now uncomment out one the first color theme to make it easy to identify which project area you are working in and comment out the active color theme if you have one activated. If you don’t like this theme, change it later. Just uncomment out the first one for now.

That’s it. Leave everything else the same and save the file, unless you are using a taskserver. In which case, do Step 3c:

Step 3c: If you are using a taskserver, change taskd.credentials

If you are syncing your tasks with taskserver, you’ll want to create a user account in a different organization with a new key. Once you do that, replace the value of taskd.credentials with your new Org/User/Key credentials.

Step 4: Set the value of the $TASKRC environment variable

This is where the magic happens. Set the value of $TASKRC with the following bash command:

export TASKRC="$HOME/.taskrc_work"

Step 5: See if the new color theme is working

Issue the following command:

task list

You should now see all of your tasks in the new color scheme. If not, go back and check your work and try again. You’ll also see a message above your task list that warns you that you have overridden the default TASKRC file.

Step 6: Delete the tasks in the new .task_work directory

Go through and delete all your personal tasks from the list using the usual task commands leaving just the work ones behind. Alternatively, if you don’t want to keep any of the tasks and are starting fresh, remove all the *.data files from the .task_work directory:

rm -f ~/.task_work*.data

Step 7: Set up aliases to make it more convenient to switch between project areas

First, add an alias to switch to your work project area. Add this alias to the appropriate bash configuration file of your choosing:

alias wtasks="export TASKRC=$HOME/.taskrc_work"

And now add an alias to unset the TASKRC variable:

alias ptasks=‘unset TASKRC’

That’s it! Now you can quickly switch between project areas. If you’d like to set up more project areas, just follow the steps above for each project area.

If you’d like to also be able to manipulate tasks in one project area while in another, proceed to the next step.

Step 8: Set project area aliases for the task command (OPTIONAL)

Let’s say you are at work and think of something important that you need to take care of to get ready for vacation. Instead of switching to your personal tasks, adding the task, and then switching back, there is another feature TW provides so you can temporarily modify the settings in your .taskrc file for a single command.

This is done by adding an override to the task command. It’s simple and it looks like this:

task <override> <command>

So if you are at work and wish to screw the man and view your personal tasks, you can do this:

task rc.data.location=~/.taskrc list

You don’t want to have to type all that in, however, so save your future self some aggravation and set up aliases for the task command for each work area:

alias taskw='task rc.data.location=~/.taskrc_work'
alias taskp='task rc.data.location=~/.taskrc'

Now you can quickly issue task commands to any work area. Great!

« Back