De vez en cuando puede ser útil agregar algunos recordatorios a Reminders.app desde la línea de comandos, especialmente porque están sincronizados con iCloud. ¿Hay alguna manera de hacerlo?
Se prefiere una solución que no dependa de AppleScript : a) por razones de rendimiento (probablemente una tontería) yb) las soluciones de AppleScript a menudo me parecen torpes o demasiado detalladas.
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
También puede crear un flujo de trabajo de Automator con solo una acción de Nuevo elemento de recordatorios vacío y luego ejecutarlo con automator -i title test.workflow
.
Consulte también esta publicación en Mac OS X Sugerencias .
#!/usr/bin/env bash
como primera línea y ejecute chmod +x /path/to/script
, o ejecute bash /path/to/script.sh
. O elimine la primera y la última línea y guárdelo Editor AppleScript.tell
con ellas?Aquí hay otra versión que le permite establecer el título, la fecha y la hora de finalización a través de argumentos de línea de comando.
#!/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
Entonces, si tuviera que llamar a este script "recordar" y darle privilegios de ejecución (recordar chmod 755), podría hacer esto:
$ ./remind "Go to grocery store" 12/15/2013 10:00:00PM
Aquí está la misma funcionalidad que el AppleScript anterior; pero en JXA con ES6.
#!/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);
}
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}
Este proyecto de github funciona muy bien y no usa AppleScript. Es una aplicación XCode compilada.
Daniel