todo icon indicating copy to clipboard operation
todo copied to clipboard

stdin [FEATURE]

Open genesistms opened this issue 3 years ago • 2 comments

It would be nice if todo can take tasks from stdin.

Usage Add tasks echo banana orange | todo add or cat my_issues.txt | todo add

Mark done tasks start with 'today': todo raw todo | grep '^today' | todo done

Possibilities would be endless.

Nice tool, btw!

genesistms avatar Sep 29 '21 06:09 genesistms

Very nice idea!

ezdux avatar Sep 29 '21 12:09 ezdux

I decided to add stdin support for adding tasks to my own todo program, inspired by this one (out of respect I wont link it, but if you stalk me a little bit you can find it).

I just want to make a few comments on this:

When using stdin, I think it is best to use newlines to delimit tasks.

Piping the output of todo raw [todo/done] into todo done (or other todo commands) wont work as it's currently designed, even if todo done is changed to read from stdin. todo done expects the indices of the tasks which should be changed, which todo raw doesn't print at all.

I got around this by modifying my todo raw to print the index at the start of each line. Like this, you can get the same output as todo raw currently prints by doing todo raw | cut -f2- -d' ', and you can mark done tasks that start with 'today' like this: todo done $(todo raw todo | grep "^[0-9]* \[.\] today" | cut -f1 -d' '). This doesn't even need stdin support :)

Zambito1 avatar Oct 04 '21 02:10 Zambito1