todo (720B)
1 #!/usr/bin/env bash 2 # 3 # z3bra - (c) wtfpl 2014 4 # Manage a todo list 5 # The file is just plain text, with one line per task 6 # This script just provide "shorter" commands to append to the file and display 7 # its content. For more complex tasks, use other tools like `sed`. 8 9 #Where's the file ? 10 TODO=${TODO:-$HOME/.todo} 11 12 list() { 13 # WHOA MUCH CLEVER!! 14 test -f $TODO && nl $TODO 15 } 16 17 append() { 18 # append all arguments "as-is" to the file 19 echo "$*" >> ${TODO} 20 } 21 22 delete() { 23 test -n "$1" || exit 1 24 ed $TODO << EOF >/dev/null 25 ${1}d 26 w 27 q 28 EOF 29 } 30 31 # delete line "$2" (see delete() function) 32 test "$1" = '-d' && delete "$2" && exit 0 33 34 # append arguments to the file, or print it otherwise 35 test -n "$*" && append $* || list 36 37 exit 0