TODO="Todo" # your todo list name in reminder ARCHIVE="Archive" # your archive list name in reminder
reminder=$(osascript -e "tell application \"Reminders\" set activeReminders to (reminders of list \"$TODO\" whose completed is true) set numOfActiveReminders to (count of activeReminders) set allReminders to (reminders of list \"$TODO\") set numOfAllReminders to (count of allReminders) set result to ((numOfActiveReminders as string) & \"/\" & numOfAllReminders as string) return result end tell")
todolist=$(osascript -e "tell application \"Reminders\" set todos to (reminders of list \"$TODO\" whose completed is false) set newlist to {} repeat with todo in todos copy (name of todo as text) to the end of the newlist end repeat return newlist end tell")
todolist=${todolist// /#holder} # 删除空格 todolist=${todolist//,/ } # 转换 AppleScript 的 list 为 shell 的 list 格式
if [ "$1" = "done" ]; then osascript -e "tell application \"Reminders\" set activeReminders to (reminders of list \"$TODO\" whose completed is false) repeat with todo in activeReminders if (name of todo as text) is equal to \"$2\" then tell todo set completed to true end tell end if end repeat end tell" fi
if [ "$1" = "open" ]; then osascript -e 'tell application "Reminders" to activate' fi
if [ "$1" = "archive" ]; then osascript -e "tell application \"Reminders\" set output to \"\" set newList to list \"$ARCHIVE\" show newList repeat with thisReminder in (get reminders in list \"$TODO\" whose completed is true) set nameObj to name of thisReminder move thisReminder to newList end repeat return output end tell" fi