todo.sh 674 B

123456789101112131415161718192021222324252627282930313233343536
  1. # This file is dedicated to the public domain.
  2. todo() {
  3. if [ $# = 0 ]; then
  4. printf "Active TODO list:\n\n"
  5. ls TODO/ | {
  6. while read _l; do
  7. printf " * %s: " "$_l"
  8. head -n1 "TODO/$_l"
  9. done
  10. }
  11. return
  12. fi
  13. if [ $# != 1 ]; then
  14. echo "expected 0 or 1 argument(s)"
  15. return
  16. fi
  17. if [ -f "TODO/$1" ]; then
  18. printf "Active TODO item: "
  19. _f="TODO/$1"
  20. elif [ -f "TODO/.$1" ]; then
  21. printf "Inactive TODO item: "
  22. _f="TODO/.$1"
  23. else
  24. echo "TODO item not found: $1"
  25. return
  26. fi
  27. head -n1 "$_f"
  28. printf "\n"
  29. sed -n '/^====$/,$p' "$_f"
  30. printf "====\n\nMentions in project:\n"
  31. git grep -Fn "TODO($1)" || echo "<none>"
  32. }
  33. # vi: sw=4 ts=4 noet tw=80 cc=80