Run programming languages from finder

On double-click the Mac OS X finder opens the default editor for script files. With the Automator you can very easy create services, which run these scripts. This example shows how to run python direct from finder.

Steps

Start Automator and select “Service”

automator service

The service should receive “Files and Folder” on “Finder”.

Service receive files and folders

Now add from library “Run as Shellscript” with following content.

Run Shell Script

for f in "$@"
do
    python "$f"
done

Now save your Automator workflow. The location should be automatically set to: “/Users/<user>/Library/Services”. Now select a python file, over the context menu or navigation item service, you can run it directly. My service is called “RunAsPython.

automator service for python