Osascript Compile Application
The answer to this is surprisingly simple:
$ osacompile -o output.app input.applescript
This works for both plaintext .applescript
files and the .scpt
files that Script Editor makes.
You can use a pipe too, e.g. if you have the script on your clipboard:
$ pbpaste | osacompile -o output.app
Or -e
, like the osascript
command can use:
$ osacompile -o output.app -e "$(pbpaste)"
You can also use JavaScript with the -l
flag:
$ osacompile -o output.app -l JavaScript -e 'app = Application.currentApplication();' -e 'app.includeStandardAdditions = true;' -e 'app.displayDialog("hi");'