7

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.

Slava Semushin
  • 13,753
  • 7
  • 47
  • 66
dave
  • 827
  • 1
  • 7
  • 18

3 Answers3

18

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.

jazmit
  • 4,464
  • 25
  • 36
  • 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 Jul 15 '15 at 05: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 Jul 15 '15 at 09: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 Jul 15 '15 at 09:55
  • 1
    Actually this one liner exactly answered my same question. – Steven R. Loomis Dec 04 '20 at 16:14
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!

ryan
  • 21
  • 1
0

If using Linux, MacOS etc:

task | grep -v ProjectName
jazmit
  • 4,464
  • 25
  • 36
  • Probably not super useful if the his project name is actually "C", task descriptions may contain "C" – Pete May 11 '18 at 18:24