Hello @silasdb! The _list
function is exported and can be used by add-ons to output tasks with the common numbering and formatting. For task ordering, there's the TODOTXT_SORT_COMMAND
hook. So, a minimal add-on could set its own sorting command (sort
, awk
, or similar) and then invoke the built-in listing of the todo.txt file:
TODOTXT_SORT_COMMAND='awk ...'
_list "$TODO_FILE" "$@"
Here's a simple but complete example from my own add-ons.
_list
renders the task numbers based on the passed lines, that does not work; the numbering would be off. However, because completely empty lines are suppressed, blanking out those lines that you don't want (but keeping the newline to maintain the right numbering) will do what you want.
due
add-on has (more or less) the same functionality as the original Python one, I would keep the name; in the end, what's most important is how you best remember the add-on name. The add-on directory also lists several alternatives with the same name.
No, as
_list
renders the task numbers based on the passed lines, that does not work; the numbering would be off. However, because completely empty lines are suppressed, blanking out those lines that you don't want (but keeping the newline to maintain the right numbering) will do what you want.
I was wondering how I can use that. I cannot pass lines to _lines via stdin. Should I have to create a temporary files with the lines I want to output via _list?
_format()
is invoked by _list()
, too; just the summary footer is missing. You should be able to avoid using a temporary file (though that certainly is not too bad, neither). Todo files aren't that large; it should comfortably fit into memory, so holding the (filtered) contents in a Bash variable (and then echo
ing that into _list()
should be possible.
@ransome1 I went into more detail on the Github issues section, but the short answer is yes, I think the listed filters should shrink based on the amount of visible todos.
Here's my answer! ransome1/sleek#4
@ransome1 Works great! I've also got it via snap on Ubuntu 20.04 so it updated automatically there this morning!
Thank you for this app! I like the fact that it's multi-platform as well; I've been looking to share a todo.txt process with some folks using different OS's. I'll let you know if we discover anything in that process!
Hey @silasdb; great work, and thank you for publishing the results so that others can reuse them! As a wiki page, the todotxt.org add-ons page should be editable by everyone, so go ahead and add links to your work.
For my own configuration, I've achieved something similar, but I chose a different approach; I have a dateex
extension of the date
command, and I'm injecting this into all of todo.txt via a shell date() { dateex "$@"; }; export -f date
function in todo.cfg
. So I don't need a custom add-on like your d
(but I think the way you've implement that as a wrapper is quite elegant), but I'm limited to generic dates (due:tomorrow
) and cannot use shortcuts like due:+1
.
add
action, and process any m:marker
or m:(marker with spaces)
syntax by expanding human-readable or relative dates (and also relative task references), via this script. I could directly use my custom dateex
there, but by overriding the original date
command, it automatically also gets used in other add-ons (for example, I use a schedule
command for tasks due in the future).
d
is such a small name that is easy to write but difficult to reason about. Do you see any problem with that?