2017-08-05 19:26:44 +01:00
|
|
|
# osascript
|
|
|
|
|
2023-07-16 18:23:40 +01:00
|
|
|
> Run AppleScript or JavaScript for Automation (JXA).
|
2021-11-02 13:02:04 +00:00
|
|
|
> More information: <https://ss64.com/osx/osascript.html>.
|
2017-08-05 19:26:44 +01:00
|
|
|
|
|
|
|
- Run an AppleScript command:
|
|
|
|
|
2022-02-14 11:21:43 +00:00
|
|
|
`osascript -e "{{say 'Hello world'}}"`
|
2017-08-05 19:26:44 +01:00
|
|
|
|
|
|
|
- Run multiple AppleScript commands:
|
|
|
|
|
2022-02-14 11:21:43 +00:00
|
|
|
`osascript -e "{{say 'Hello'}}" -e "{{say 'world'}}"`
|
2017-08-05 19:26:44 +01:00
|
|
|
|
2017-09-04 23:55:11 +01:00
|
|
|
- Run a compiled (`*.scpt`), bundled (`*.scptd`), or plaintext (`*.applescript`) AppleScript file:
|
2017-08-05 19:26:44 +01:00
|
|
|
|
2017-09-04 23:55:11 +01:00
|
|
|
`osascript {{path/to/apple.scpt}}`
|
2017-08-05 19:26:44 +01:00
|
|
|
|
|
|
|
- Get the bundle identifier of an application (useful for `open -b`):
|
|
|
|
|
|
|
|
`osascript -e 'id of app "{{Application}}"'`
|
|
|
|
|
|
|
|
- Run a JavaScript command:
|
|
|
|
|
2022-02-14 11:21:43 +00:00
|
|
|
`osascript -l JavaScript -e "{{console.log('Hello world');}}"`
|
2017-08-05 19:26:44 +01:00
|
|
|
|
|
|
|
- Run a JavaScript file:
|
|
|
|
|
|
|
|
`osascript -l JavaScript {{path/to/script.js}}`
|