commit - b9a2c057ae152cfffda3e6ce7b22a0584bb24e32
commit + 84d6904dd281fc3a5ca915f5383b6744cbaf6263
blob - 8d516126b0eb0bb9c756be5057d911a76ef2a14a
blob + ee3aebb92b4b982a7319da753851ed362aad9289
--- todo.sh
+++ todo.sh
test -f "$todo_file" || fail "TODO_FILE not found"
usage() {
- echo "usage: $program [-e]"
- echo " $program [-d NUM]"
- echo " $program TASK"
+ echo "usage: $program TASK"
+ echo " $program [-d LINENUM] [-e] [-Ss QUERY]"
}
# t_done(int)
int=$1
tmpfile=$(mktemp)
sed -n "${int}!p" "$todo_file" > "$tmpfile"
+ mv "$todo_file" "${todo_file}~"
mv "$tmpfile" "$todo_file"
}
t_print() {
lines=$(wc -l < "$todo_file")
width=$(echo $lines | wc -c)
- nl -s' ' -w"${width}" "$todo_file"
+ nl -s' ' -w"$width" "$todo_file"
}
main() {
- if getopts hed: opt; then
+ if getopts hed:S:s: opt; then
case "$opt" in
(e) $EDITOR "$todo_file"
exit ;;
(d) t_done "$OPTARG"
exit ;;
+ (S) t_print | grep -iw "$OPTARG"
+ exit ;;
+ (s) t_print | grep -i "$OPTARG"
+ exit ;;
(h) usage
exit ;;
(?) usage