dmenium

small collection of dmenu scripts
git clone git://edryd.org/dmenium
Log | Files | Refs | LICENSE

todo (539B)


      1 #!/usr/bin/env bash
      2 
      3 # TODO: | sort -s -k 1,1
      4 
      5 file=~/.todo
      6 height=$(cat $file | wc -l)
      7 prompt="Add/delete a task"
      8 
      9 if [ "$height" -gt 20 ]; then height=20; fi
     10 
     11 cmd=$(cat "$file" | dmenu $@ -l "$height" -p "$prompt:" )
     12 
     13 while [ -n "$cmd" ]; do
     14 	grep -q "^$cmd" $file
     15 	if [ $? = 0 ]; then
     16 		grep -v "^$cmd" $file > /tmp/todo
     17 		mv /tmp/todo $file
     18 		height=$((height-1))
     19 	else
     20 		echo "$cmd" >> $file
     21 		height=$((height+1))
     22 	fi
     23 	if [ "$height" -gt 20 ]; then height=20; fi
     24 	cmd=$(cat $file | dmenu $@ -l "$height" -p "$prompt:" )
     25 done
     26 
     27 exit 0