From bc2549212113219833d88ce74ade7e2eb5f9e309 Mon Sep 17 00:00:00 2001 From: Daniel Bayley Date: Sat, 5 Aug 2017 19:26:44 +0100 Subject: [PATCH] osascript: add page Also referred to from the open page. --- pages/osx/osascript.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 pages/osx/osascript.md diff --git a/pages/osx/osascript.md b/pages/osx/osascript.md new file mode 100644 index 000000000..d6b0f23ca --- /dev/null +++ b/pages/osx/osascript.md @@ -0,0 +1,27 @@ +# osascript + +> Run AppleScript or JavaScript for Automation (JXA) from the command line. + +- Run an AppleScript command: + +`osascript -e '{{say "Hello world"}}'` + +- Run multiple AppleScript commands: + +`osascript -e '{{say "Hello"}}' -e '{{say "world"}}'` + +- Run an AppleScript file: + +`osascript {{path/to/apple.scpt}}` + +- Get the bundle identifier of an application (useful for `open -b`): + +`osascript -e 'id of app "{{Application}}"'` + +- Run a JavaScript command: + +`osascript -l JavaScript -e '{{console.log("Hello world");}}'` + +- Run a JavaScript file: + +`osascript -l JavaScript {{path/to/script.js}}`