dots

Personal dotfiles
git clone git://git.gormless.xyz/dots.git
Log | Files | Refs

todo (708B)


      1 #!/bin/sh
      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     # WOAH 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     sed -i "${1}d" $TODO 
     25 }
     26 
     27 # delete line "$2" (see delete() function)
     28 test "$1" = '-d' && delete "$2" && exit 0
     29 
     30 # append arguments to the file, or print it otherwise
     31 test -n "$*" && append $* || list
     32 
     33 exit 0