Building notes, projects, and occasional rants

I'm trying to use the organizer to sort some of my work. Usually I use small 3 by 4 cards, and they are great to collect stuff to do, but they are not that great when I need to organize them into projects and define priorities.

First impressions are good. It's a simple script with a simple command line interface.

One of the first things I did was adding a short alias, t, as suggested at their site. This cuts down a lot of typing but being a lazy bastard myself, I wanted more.

So I wrote this:

# completion by Pedro Melo <[email protected]>
# for updates see:

  local cur prev commands options command

  if [ -r $TODOSHRC ] ; then

  if [ ! -r $TODO_FILE ] ; then
    echo "ERROR: cannot read todo.txt file."
    echo "Make sure TODOSHRC is set with the correct .todo config file";
    return 0


  commands='add append archive contexts del do list listpri \
            prepend pri projects replace remdup report'
  options="-d -p -q -v"

  if [[ $COMP_CWORD -eq 1 ]] ; then
    if [[ ${cur} == -* ]] ; then
     COMPREPLY=( $( compgen -W "$options" -- $cur ) )
      COMPREPLY=( $( compgen -W "$commands" -- $cur ) )

    return 0

  case "${prev}" in
      local projects=$(egrep -o 'p:\w+' $TODO_FILE | sort | uniq -c | sort -rn | awk '{ print $2 }')
      local contexts=$(egrep -o '@\w+' $TODO_FILE | sort | uniq -c | sort -rn | awk '{ print $2 }')
      COMPREPLY=( $(compgen -W "${projects} ${contexts}" -- ${cur}) )
      return 0

      local n_todos=$(wc -l $TODO_FILE)
      local tasks=$(seq 1 $n_todos)
      COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) )
      return 0

      local pris=$(egrep -o '\(\w+\)' ~/Documents/todo/todo.txt | cut -c2 | sort | uniq -c | sort -rn | awk '{ print $2 }')
      COMPREPLY=( $(compgen -W "${pris}" -- ${cur}) )
      return 0


  return 0
complete -F _todo_sh -o default

It's a bash_completion script. Copy & paste it into your own ~/.bash_completion.d/todo or the system /etc/bash_completion.d/todo.

It completes all the options and commands. It also completes @contexts and p:projects in list and add. It completes task numbers on all the commands that use them, and completes priorities in listpri.

It assumes that the configuration file is at ~/.todo. If in your case you have it in a different place, you can set the environment variable TODOSHRC.

If you, like me, added your own alias shortcut to, add this line after the alias definition:

complete -F _todo_sh -o default t

In my case, I was using the alias t for If you use another alias, replace the last t with your chosen alias.

The completion can be made smarter. Some commands need to expand to a task number and then free text, and inside the free text, expanding to @contexts or p:projects would be useful.