Skip to content

Instantly share code, notes, and snippets.

@ctkjose
Last active August 27, 2021 21:14
Show Gist options
  • Save ctkjose/e5439ec2f2628abb3c54 to your computer and use it in GitHub Desktop.
Save ctkjose/e5439ec2f2628abb3c54 to your computer and use it in GitHub Desktop.
Enable Javascript CLI on OS-X

You can run the JavaScriptCore Framework from the CLI to run javascript code.

All we have to do is create an alias to access the jsc binary easily from the CLI.

sudo ln -s /System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc /bin/jsc

To see the CLI options available visit the WebKit wiki. http://trac.webkit.org/wiki/JSC

Also using brew you can install spidermonkey.

brew install spidermonkey

Using Javascript on OSX

Javascript with Automator, shell and Apple's Open Scripting Architecture https://github.com/dtinth/JXA-Cookbook/wiki/Using-JavaScript-for-Automation https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/

Javascript options on the shell

http://www.freshblurbs.com/blog/2011/09/25/command-line-javascript-cli-mac-os-x.html

@ousjaguraga
Copy link

Thank you, this works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment