Script Monkey

Compatible with: IntelliJ IDEA PhpStorm WebStorm PyCharm RubyMine AppCode CLion GoLand DataGrip Rider MPS Android Studio
Sep 13, 2015
8 645

Script Monkey breaks the boundaries of Java and helps Java achieve the power & flexibilities of interpreted/dynamic languages. In other words, it helps Java achieve the best of both worlds.

Thanks to the embedded Rhino & Scripting API for being part of Java since v1.6. It's an all-in-one plugin which means, anything that was possible only by writing a plugin can be done using plugin-scripts(simple javascript code). And, any tasks that makes more sense to be scripted can be implemented using this tool.

Instead of explaining what this plugin can do in words, we wanted to show some in action.

  1. Say 'Hello' to Rhino
  2. Let's do some command shell scripting
  3. Timebar plugin script

Getting Started

For the latest information & documentations, please visit the project's homepage

Download plugin

Recent change notes

    Version 1.2.8 changes:
  • Fix missing scripts jar for component initialization of the scripts directory under build 142.x of IDEs.
  • Change script panels now re-use command processor between runs and enable the interactive prompt so that globals can be examined after script is evaluated to ease debugging.
  • Change result printing in interactive shell to do some formatting based on result type and also print null for commands that return null and are not all white space.
    Version 1.2.7 changes:
  • Fix EditorImpl not released, again. Finally figured out that it was the Script panels that were causing this.
  • Change code to modify classloader to find nashorn.jar to the same one used in vsch/idea-multimarkdown plugin.
  • Change ant build of source zip to put the zip under project root instead of under src so it does not complain about including itself.
    Version 1.2.6 changes:
  • Fix scripts were not stoppable via stop action. Now an attempt is made to interrupt a thread and if it does not respond within 2 seconds, then the thread is stopped. Works in all but one case which is unstoppable.
  • Add stop script action button to JS Shell pane so that accidental infinite loops could be terminated instead of hanging the shell.
  • Change JS Shell pane now flushes accumulated text from a running script every 100ms instead of waiting for it to terminate.
    Version 1.2.5 changes:
  • Fix editor was not released error, really fixed it this time.
    Version 1.2.4 changes:
  • Fix editor was not released error.
    Version 1.2.3 changes:
  • Change move global var definition in engine init to address issue #8.
    Version 1.2.2 changes:
  • Add catch assertion errors when executing commands in the shell, otherwise they abort the shell processor.
  • Add text printed to the shell pane converts \r\n and \r to \n to avoid assert fail in document insert.
  • Change timebar.js to nashorn recommended Java.type() usage and use function(){} to SAM conversion.
  • Change remove loading of nashorn:mozilla_compat.js because it screws up exception reporting in eval.
    Version 1.2.1 changes:
  • Fixed with() was hiding all engine scope bindings, now using global scope instead. The way engines are created global scopes are not shared anyway.
  • Fixed text printed through window.println via timer would be interpreted as user typed command
  • Change timebar.js to be reloadable without adding new labels
    Version 1.2.0 changes:
  • Fixed timebar.js to work with nashorn script engine.
  • Changed since build to 141 since it cannot find script engine even if running IDEA jre 1.8
  • Changed toolwindow pane to standard editor with JS highlighting. This is WIP, needs better handling of editing and executing prior command lines.
  • Add Set script file name so that exceptions report the right source
  • Add line and column offsets to exceptions reported for the Script Monkey JS Shell
    Version 1.1.1 changes:
  • Compatible with IntelliJ v14 and v15 EAP ommunity Edition & WebStorm
    Version 1.0.2 changes:
  • Compatible with IntelliJ v12 Community Edition & WebStorm