Skip to main content

Execute Scripts on Startup

When starting Ocular, you can choose to have scripts automatically executed.

Executing Scripts for a Specific Session

You can execute initialization scripts for a specific session

As an example, let's say that you have a script,, with the following contents:

echo 'def foo = 42' > scripts/

Start Ocular using sl ocular, load your CPG, and use the runScript command:


You'll see the following responses as Ocular runs your script:

ocular> foo
res0: Int = 42

Executing Scripts for all Sessions

To execute initialization code every time you start Ocular, write it to a .sc file in your ~/.shiftleft/ocular directory. We recommend calling your file, but by default, Ocular executes all of the files with the .sc extension in that directory whenever it starts.

As an example, let's say that you've created your file as follows:

echo 'def foo = 42' > ~/.shiftleft/ocular/

Start Ocular using sl ocular. You'll see the results of the file having been run:

ocular> foo
res0: Int = 42