taskwarrior conditional in filter

1.8k Views Asked by At

Does anyone know if a conditional (such as 'not') can be applied in a taskwarrior filter.

I want to list all tasks except for the ones related to one project.

Say I have projects A thru F, I want all tasks except the ones from project C. It looks like this is possible with tags (using a negative sign) but I cannot get it to work for projects.

3

There are 3 best solutions below

5
On BEST ANSWER

You can use the ".not" modifier on any of the TaskWarrior filters, which flips the selection of tasks. Typing

task project:C

would select all the tasks in project C, so:

task project.not:C

selects all tasks not in project C.

0
On

When calling taskwarrior, just list the projects that you want see.

So, in your case to see only Projects A, B, D, E, and F you'd call taskwarrior like this:

task '(project:A or project:B or project:D or project:E or project:F)' ls

Let's look at an example of this. Say you have 3 projects like the ones below:

task list +stackoverflow

ID Age  D Project Tags          Description Urg 
59 6min   Test1   stackoverflow Task 1       1.8
60 5min   Test2   stackoverflow Task 1       1.8
61 4min   Test3   stackoverflow Task 1       1.8

If we just wanted to see the tasks for projects Test1 and Test2 we'd call taskwarrior like this:

task '(project:Test1 or project:Test2)' list +stackoverflow

Our output would look like this:

ID D Project Tags          Description
59   Test1   stackoverflow Task 1     
60   Test2   stackoverflow Task 1     

I hope that helps!

1
On

If using Linux, MacOS etc:

task | grep -v ProjectName