-
Notifications
You must be signed in to change notification settings - Fork 6
How Script Monkey Works
When Script Monkey is installed for the first time, it creates a scriptMonkey
subdirectory in the user's default home folder. This is system dependent and in Windows it is C:\Documents and Settings\siddique\scriptMonkey
and in Unix it is /home/siddique/scriptMonkey
. Under the scriptMonkey folder, it copies all the script files bundled in the plugin's script package (js.jar
).
The directory structure will look something similar to this
scriptMonkey
└── js
├── global
│ ├── gui.js
│ ├── gui.js.bak
│ ├── init.js
│ ├── init.js.bak
│ ├── intellij.js
│ └── intellij.js.bak
├── lib
│ └── trimpath.js
├── plugin-script
│ ├── codespointer.js
│ ├── codespointer.js.bak
│ ├── timebar.js
│ ├── timebar.js.bak
│ ├── tools.js
│ └── tools.js.bak
└── samples
├── AntVersion.js
├── AntVersion.js.bak
├── BackupProjectFolder.js
├── BackupProjectFolder.js.bak
├── EchoEnvironmentVariables.js
├── EchoEnvironmentVariables.js.bak
├── FileStatistics.js
├── FileStatistics.js.bak
├── HelloRhino.js
├── ZipAndEmailProject.js
└── ZipAndEmailProject.js.bak
5 directories, 24 files
When you update the plugin, new scripts from the new plugin will be copied to this directory.
All the scripts located in the js/global
folder will be executed for every instance of the script engine, with no particular order of precedence given to the scripts. If you want to add more global objects or functions, you can create a script file and place it inside the global folder.
Plugin scripts are script files that will get automatically executed by by Script Monkey on the following configurable events:
- On IntelliJ IDE Startup
- On Project Open
- On Project Close
- On IntelliJ IDE Shutdown
Some plugin scripts, like timebar.js
are bundled with the plugin for demonstration. If you want to add a new plugin script, you can do so in Settings > Other Settins > Script Monkey, select the Plugin Scripts tab and click the Add button.
There is nothing special about the plugin-script
folder. You can add script files from any location on your system.
Feel free to add and change the scripts provided in the samples
folder. If you want to contribute your own scripts, please do post them on the Script Monkey Issues page on GitHub
The Command Shell is useful for testing and exploring the nashorn script engine and Script Monkey capabilities. If you type help(), you would see a list of global functions with one line comments describing them. All the global objects & functions that are part of the global scripts are available in the Command Shell context.
For example, application
global object was initialized in the intellij.js
script. If you type application.name
you will get the name of the application the script is running in, which is "idea"
You can run a .js
script file by navigating the main menu to Script Monkey > Run Script or from the Run Script context menu. Global objects & function are available to the scripts invoked with Run Script.
When you run a script in the Script Monkey JS Shell
or invoke it with the Run Script context menu item, you can interrupt its execution by pressing the stop button in the Script Monkey tool window.