cyclenext – a script to monitor taskwarrior tasks continously

Intro

Update: I implemented the script in python (I still did not figure out how to calculate the task limit porperly). Check out the github project.

I’m using taskwarrior for about 19 months now, during that time I logged about 1000 tasks. Even during those times where I did not live full time on the command line it served me well and never got in the way: Once it output the task I asked for return to the bash prompt and I could carry on with whatever I wanted to do.

This also means that there is no continous view of all the tasks at hand, a feature that I found useful at some times. The naive approach to achieve this would be a bash command like this:

for ( (;;) ) do clear; task next rc.gc=off; sleep 5; done

If you ever did something like this, you know that this leads to unpleasant (because irritating) screen flicker every 5 seconds (or whatever you set the delay to). This is the reason why I hacked together the first iteration of a simple script I called „cyclenext“. After I finally switched to taskwarrior version 2.2.0 I wanted to share this with everybody who is interested.

Usage

Nothing fancy there: First edit the location of your taskwarrior „pending.data“ file and then use it like this:

cyclenext <filter>

where can be everything from „next“ to more complex filters like „ready project:worldpeace prio:h“. Press <ctrl>+<c> (or <cmd>+<c>) to end cyclenext.

How it works

Cyclenext checks the „last modified“ timestamp of your „pending.data“ „undo.data“ file every two seconds, and then clears the screen and outputs the task list whenever a change occured. Cyclenext also redraws the screen every 5 minutes just in case you made edits to your taskwarrior configurations files.

Cyclenext uses the „rc.gc=off“ option to preserve the task numbers. The signal for a change in the size of the terminal window is detected and also leads to a new output of the task list. Here you can view the whole beauty as a gist:

Issues

Cyclenext is currently still horrible when it comes to dealing with the numbers of tasks to display. The reason for this is that taskwarrior allows an option to limit the numbers of tasks to be output („limit:“). But a task can occupy several lines if it has annotations or the task description is wrapped over several lines. The current approach is to determine the lines available in the terminal window and then to reserve a fixed amount of lines (20) to allow for line wrapping.

Another (IMO minor) flaw is that a monitoring of changes in the completed data (which result in changes in the completed.data file) is not possible. The solution is to monitor undo.data: This changes on every „add“, „done“, „mod“ or „log“ operation.

Download

The best thing is to download the script directly from github. Changes will be reflected there. Feel free to comment!

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *