9

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 Answers 3

26

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.

5
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.
    – Mohit Jain
    Commented Jul 15, 2015 at 5:11
  • 1
    Why doesn't it answer the question? @dave wants to list all tasks except for those in project C, which is what this does.
    – jazmit
    Commented Jul 15, 2015 at 9:43
  • One liners look more suitable for comments to get clarification to suggest to try something. Without details many readers like me can not understand the answer. Adding some details would provide usefulness to the answer and would garner more upvotes. One liners may get deleted during audit.
    – Mohit Jain
    Commented Jul 15, 2015 at 9:55
  • 1
    Actually this one liner exactly answered my same question. Commented Dec 4, 2020 at 16:14
  • A version of this one-liner is also useful to select all non-null attributes. For example, to select only tasks that have any priority assigned, use task priority.not: -- that is, with the 'not' qualifier applied, but no value following the colon.
    – rd_nielsen
    Commented Jan 27 at 15:44
2

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!

0

If using Linux, MacOS etc:

task | grep -v ProjectName
1
  • Probably not super useful if the his project name is actually "C", task descriptions may contain "C"
    – Pete
    Commented May 11, 2018 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.