todomenu 463 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. file="$HOME/documents/.todo"
  3. touch "$file"
  4. height=$(wc -l "$file" | awk '{print $1}')
  5. prompt="Tasks:"
  6. cmd=$(dmenu -l "$height" -i -p "$prompt" "$@" < "$file")
  7. while [ -n "$cmd" ]; do
  8. if grep -q "^$cmd\$" "$file"; then
  9. grep -v "^$cmd\$" "$file" > "$file.$$"
  10. mv "$file.$$" "$file"
  11. height=$(( height - 1 ))
  12. else
  13. echo "$cmd" >> "$file"
  14. height=$(( height + 1 ))
  15. fi
  16. cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file")
  17. done
  18. exit 0