Answers:
osascript - title <<END
on run a
tell app "Reminders"
tell list "Reminders" of default account
make new reminder with properties {name:item 1 of a}
end
end
end
END
您还可以使用一个空的“新提醒项”操作创建一个Automator工作流程,然后使用来运行它automator -i title test.workflow
。
另请参阅Mac OS X提示上的这篇文章。
#!/usr/bin/env bash
为第一行并运行chmod +x /path/to/script
,或者运行bash /path/to/script.sh
。或删除第一行和最后一行并将其保存为AppleScript编辑器。
这是另一个版本,允许您通过命令行参数设置标题,结束日期和时间。
#!/usr/bin/env bash
# Make a new reminder via terminal script
# args: remind <title> <date> <time>
osascript - "$1" "$2" "$3" <<END
on run argv
set stringedAll to date (item 2 of argv & " " & item 3 of argv)
tell application "Reminders"
make new reminder with properties {name:item 1 of argv, due date:stringedAll}
end tell
end run
END
因此,如果要将此脚本命名为“ remind”并赋予其执行特权(chmod 755提醒),则可以执行以下操作:
$ ./remind "Go to grocery store" 12/15/2013 10:00:00PM
tell application "Reminders"
activate
show list "Reminders"
end tell
set stringedDate to "12/11/2015"
set stringedHour to "10:00:00PM"
set stringedAll to date (stringedDate & " " & stringedHour)
tell application "Reminders" to tell list "Reminders" of default account to make new reminder with properties {name:"this is just test remainder", remind me date:stringedAll, due date:stringedAll, priority:1}
这与上面的AppleScript具有相同的功能;但是在带有ES6的JXA中。
#!/usr/bin/env osascript -l JavaScript
const RemindersApp = Application('Reminders');
function run(argv) {
[name, date, time] = argv;
dueDate = new Date(date + " " + time);
reminder = RemindersApp.Reminder({name: name, dueDate: dueDate});
RemindersApp.defaultList.reminders.push(reminder);
}
这个github项目运作良好,并且不使用AppleScript。这是一个编译的XCode应用程序。