todo (592B)
1 #!/bin/sh 2 # 3 # Write/remove a task to do later. 4 # 5 # Select an existing entry to remove it from the file, or type a new entry to 6 # add it. 7 # 8 9 file="$HOME/.todo" 10 touch "$file" 11 height=$(wc -l "$file" | awk '{print $1}') 12 prompt="Add/delete a task: " 13 14 cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file") 15 while [ -n "$cmd" ]; do 16 if grep -q "^$cmd\$" "$file"; then 17 grep -v "^$cmd\$" "$file" > "$file.$$" 18 mv "$file.$$" "$file" 19 height=$(( height - 1 )) 20 else 21 echo "$cmd" >> "$file" 22 height=$(( height + 1 )) 23 fi 24 25 cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file") 26 done 27 28 exit 0