18 lines
594 B
Bash
Executable File
18 lines
594 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# description: Remove completed (checked) tasks from the session plan
|
|
# Args: (none)
|
|
|
|
[ -z "$OLLIE_SESSION_ID" ] && echo "error: OLLIE_SESSION_ID not set" >&2 && exit 1
|
|
|
|
OLLIE="${OLLIE:-$HOME/mnt/ollie}"
|
|
plan="$OLLIE/s/$OLLIE_SESSION_ID/plan"
|
|
|
|
[ ! -f "$plan" ] && echo "no plan found" && exit 0
|
|
|
|
before=$(grep -c '^\- \[.\]' "$plan" 2>/dev/null || echo 0)
|
|
grep -v '^\- \[x\]' "$plan" > "$plan.tmp" && mv "$plan.tmp" "$plan"
|
|
after=$(grep -c '^\- \[.\]' "$plan" 2>/dev/null || echo 0)
|
|
|
|
removed=$(( before - after ))
|
|
echo "cleared $removed completed task(s), $after remaining"
|