JXA
Notes #
JXA = JavaScript for Automation
Run Shell Script #
const app = Application.currentApplication();
app.includeStandardAdditions = true;
const path = app.doShellScript('pwd');
Write to a File #
const path = '/Users/foo/info.txt'
const dataToWrite = 'this is some text'
const file = app.openForAccess(Path(path), { writePermission: true })
app.setEof(file, { to: 0 })
app.write(dataToWrite, { to: file, startingAt: app.getEof(file) })
app.closeAccess(file)
Read plist file #
const data = se.propertyListFiles.byName(`path/to/info.plist`).contents.value()
Open Calendar at Date #
var app = Application.currentApplication()
app.includeStandardAdditions = true
var Calendar = Application("Calendar")
var date = new Date()
Calendar.switchView({ to: "day view" })
Calendar.viewCalendar({ at: date })