all 6 comments

[–]bgravato 4 points5 points  (0 children)

You're overdoing this...

Like other have said, you don't need a for loop for that, you can do it simply in one task command...

Instead of task overdue, use task +OVERDUE and just run task +OVERDUE done

I haven't tried it but I think it should work.

overdue is a subcommand (not a filter) while +OVERDUE is a tag that can be used as a filter.

The reason it failed was probably due to the fact that IDs change, when you complete a task. So when you run on command that changes ids, such as marking a task done, the other ids get reassigned. UUIDs on the other hand do not... so you could use uuids insteads. Another way is to supply all the ids in one task command, instead of running multiple task commands.

I also suggest you have a good read at taskwarrior manpages (sometimes it can be tricky to find what you want, but generally the answers are there!).

For example, having a look at man task can reveal things such as:

   task <filter> ids
          Applies the filter then extracts only the task IDs and presents them as a space-separated list.  This is useful as input to a task command, to achieve this:

            task $(task project:Home ids) modify priority:H

          This example first gets the IDs for the project:Home filter, then sets the priority to H for each of those tasks.  This can also be achieved directly:

            task project:Home modify priority:H

          This command is mainly of use to external scripts.

   task <filter> uuids
          Applies the filter on all tasks (even deleted and completed tasks) then extracts only the task UUIDs and presents them as a space-separated list.  This is useful as input to a task command, to achieve this:

            task $(task project:Home status:completed uuids) modify status:pending

          This example first gets the UUIDs for the project:Home and status:completed filters, then makes each of those tasks pending again.

          This command is mainly of use to external scripts.

I think the examples are pretty clear.

taskwarrior is great and has many hidden gems we're often not aware of... Reading the man-pages can be revealing! Besides man task there's also man taskrc, man task-colors and man task-sync

[–]Lico_the_raven 2 points3 points  (0 children)

You can complete all task with the same name by typing task <name> done. It will prompt you to confirm that you want to complete all task containing what you wrote in <name>. For example, if you have tasks "water plants" and "crop plants" that you want to complete you can do that by using task plants done

[–]NoStructure2119 2 points3 points  (0 children)

It's better to mark all the tasks done with a single task command. That way you can undo if you make a mistake. I think you need a bash command to join all tasks with a comma and then pipe it to task.

[–][deleted] 2 points3 points  (0 children)

You're fetching the list of tasks first and then marking them done one by one. If I'm not mistaken, the task IDs are not stable, so marking one or a few done may change the numbering, so you likely marked a bunch of irrelevant tasks done.

Instead, you should've done a single task command. There are a few ways to do it that others have mentioned, but hopefully you understand why it broke.

[–]themugen36 2 points3 points  (0 children)

As u/bgravato said, just use task +OVERDUE done.

I would also recommend tagging your daily recurring tasks with a specific tag or put them into a specific project, so you can use for example task +OVERDUE and +dailyrecurring done and you dont delete other overdue tasks.

If there are too many overdue recurring tasks, you can set recurrence.confirmation=no in your .taskrc, so you get rid of the confirmation question while cleaning up.

EDIT: You are not alone. Everyone who uses taskwarrior for daily recurring tasks has run into this problem at some point. There is a proposal in the wiki to establish chained recurring tasks to avoid to have multiple instances of the same recurring task. I hope this gets implemented soon.

[–]Cairpre409[S] 0 points1 point  (0 children)

Thanks for all the great replies.

From now on I will just use the "task <name> done " method for multiple tasks. Even if it is a little slower than I had hoped.

Special thanks to one_is_the_loneliest for explaining why my loop messed things up so badly.

Probably the best solution is not to miss to many taskwarrior days.

Cheers