#!/bin/sh # acmetodo-add: Adds a new todo item. PLAN9=${PLAN9:-"/usr/local/plan9"} TODO_FILE="$PLAN9/lib/todo" ACME_BIN="$PLAN9/bin/acme" # Prompt for subject in Acme's current window (where the command was issued) # Output to stderr so it doesn't interfere with potential stdout pipe. echo -n "Subject: " >/dev/stderr read subject if [ -n "$subject" ]; then echo "[ ] $subject" >> "$TODO_FILE" # Find the winid of the main acmetodo window to refresh it. # This assumes the main acmetodo window's name is the TODO_FILE path. MAIN_TODO_WINID=$($ACME_BIN -w | grep "^$TODO_FILE" | cut -d' ' -f1 | head -n 1) if [ -n "$MAIN_TODO_WINID" ]; then echo 'Get' | $ACME_BIN -a "$MAIN_TODO_WINID" else echo "Warning: Main acmetodo window not found to refresh." >/dev/stderr fi else echo "No subject provided. Item not added." >/dev/stderr fi