about summary refs log tree commit diff stats
path: root/bash/acmetodo-filter
diff options
context:
space:
mode:
Diffstat (limited to 'bash/acmetodo-filter')
-rw-r--r--bash/acmetodo-filter22
1 files changed, 22 insertions, 0 deletions
diff --git a/bash/acmetodo-filter b/bash/acmetodo-filter
new file mode 100644
index 0000000..6149207
--- /dev/null
+++ b/bash/acmetodo-filter
@@ -0,0 +1,22 @@
+#!/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
\ No newline at end of file