blob: b40663d8a224ce76de77b8906acd127ff3e8c645 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/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
|