Skip to content

Instantly share code, notes, and snippets.

@samstokes samstokes/todo
Last active Nov 2, 2018

What would you like to do?
A todo management system in a gist
#!/bin/bash -e
if [[ $# > 0 ]]; then
case "$1" in
-h | -\? | --help )
echo "Add a todo:"
echo " todo Reformulate the widget plans."
echo "See what you have to do:"
echo " todo"
echo "After you've done item 4:"
echo " todo -4"
echo "Count items left to do:"
echo " todo -c"
echo "Edit the todo list directly (using $EDITOR):"
echo " todo -e"
} >&2
-c | --count )
if [ -r TODO ]; then
exec wc -l TODO
echo 0 TODO
-e | --edit )
exec $EDITOR TODO "$@"
-* | x* )
lineno=$(cut -c2- <<<"$1")
sed -i "$lineno d" TODO
echo Deleted item $lineno. >&2
exec "$0"
* )
echo "$@" >> TODO
elif [ -r TODO ]; then
if grep -q . TODO; then
awk 'BEGIN { n = 1 } { printf "[%d]\t%s\n", n, $0; n = n + 1 }' TODO
echo Nothing to do!
echo Nothing to do!

This comment has been minimized.

Copy link
Owner Author

samstokes commented Apr 16, 2013

If I'm working on something in a terminal (coding, code review, documenting), I often want somewhere to jot down things I just thought of, so I can come back to them later. They tend to be too fine-grained / low-level / transient to keep in a proper task manager or bug tracker. A file in the working directory is just right.

This makes it a tiny bit easier to maintain such a file, without sacrificing the power of plain text. Want to filter tasks? grep. Need to edit or reorder? $EDITOR is there for you.

It's also, I think, a nice example of how useful - and readable - a brief shell script can be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.