commit 6a49fa6bbc4e812d6d88e78e50327f429378d725 parent 5a150163dd6ade7a8951b9f55bf78354cbee370e Author: Ed van Bruggen <edvb54@gmail.com> Date: Sat, 10 Dec 2016 22:29:57 -0800 Add todo.sh, a dmenu todo list Diffstat:
todo.sh | | | 27 | +++++++++++++++++++++++++++ |
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git a/todo.sh b/todo.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# TODO: | sort -s -k 1,1 + +file=~/.todo +height=$(cat $file | wc -l) +prompt="Add/delete a task" + +if [ "$height" -gt 20 ]; then height=20; fi + +cmd=$(cat "$file" | dmenu $@ -l "$height" -p "$prompt:" ) + +while [ -n "$cmd" ]; do + grep -q "^$cmd" $file + if [ $? = 0 ]; then + grep -v "^$cmd" $file > /tmp/todo + mv /tmp/todo $file + height=$((height-1)) + else + echo "$cmd" >> $file + height=$((height+1)) + fi + if [ "$height" -gt 20 ]; then height=20; fi + cmd=$(cat $file | dmenu $@ -l "$height" -p "$prompt:" ) +done + +exit 0