insh

The MEMPHYS_vis/12.x is equipped with the core of a Bourne like shell called "insh" for INlib SHell.

It had been introduced to have a way to customize things by using a scripting syntax known by any UNIX pedestrian and easily implementable by a "doer" without having to embarque a million of lines of code to do that. insh has the basic mechanisms found on any bash shell: variables, env variables, dollar replacement of a variable, execute other scripts, source other scripts and, obviously, execute commands with options. For example in the event.insh script, you can see:

    # this is a comment.
    ...   
    scene_clear_dynamic
    app_vis_beam_and_target
    m=`unit m`
    radius=`calc 0.05*${m}`  # PM size 0.15*CLHEP::m.
    g4_vis_primary_vertices -style=primary_vertex -radius=${radius}
    g4_vis_trajectories -pickable -primaries
    ...

As for a Bourne shell, at startup of the program, the internal insh will execute, if found and in this order, the files:

    ~/.insh
    ~/Documents/MEMPHYS_vis/.insh
    startup.insh
    gui_main.insh  # containing an insh description of the GUI main panel.

For example, in a .insh, you can have:

    echo 'hello my .insh'

insh maintains a PATH variable containing a ';' separated list of directory to search for files to execute. At startup this variable contains the application user 'document directory' and the internal 'resource directory'. The document directory, on a UNIX, is:

    ~/Documents/MEMPHYS_vis
 and the internal directory is of the form:
    <install_path>/MEMPHYS_vis/<version>/res

The document directory is in general the place to customize the startup.insh and even the GUI throught the gui_main.insh file. Note that the .insh are sourced, but not the startup.insh and gui_main.insh files.

At each event the event.insh is executed. startup.insh and event.insh are the typicall places were you can customize things without having to recompile the application. Commands can be added, see for example how the 'app_version' command is done in the MEMPHYS_vis/main. Most of commands are not MEMPHYS_vis specific and their code can be found under the inexlib/inlib/insh and inexlib/exlib/insh directories.

The Geant4 commands can be executed from insh by using the g4_apply_command command. For example:

    $ g4_apply_command '/run/beamOn 1'

Note that Geant4 related commands start with 'g4_'. For example:

    $ g4_pv_ls
    $ g4_lv_ls
    $ g4_material_ls

(The list of commands is in the 'help text commands' section).