#!/bin/sh # acmetodo-todo: Filters the todo list to show only 'to-do' items. PLAN9=${PLAN9:-"/usr/local/plan9"} TODO_FILE="$PLAN9/lib/todo" ACME_BIN="$PLAN9/bin/acme" # Find the winid of the main acmetodo window MAIN_TODO_WINID=$($ACME_BIN -w | grep "^$TODO_FILE" | cut -d' ' -f1 | head -n 1) if [ -z "$MAIN_TODO_WINID" ]; then echo "Error: Main acmetodo window not found." >/dev/stderr exit 1 fi # Filter the content and send it back to the window filtered_content=$(grep '^[ ] ' "$TODO_FILE") # Clear current window content and then write the filtered content echo 'data' | $ACME_BIN -a "$MAIN_TODO_WINID" echo "$filtered_content" | $ACME_BIN -a "$MAIN_TODO_WINID" echo 'clean' | $ACME_BIN -a "$MAIN_TODO_WINID" # Mark window as clean after update