Shell snippet

It's possible to work with a Bash shell on Unix like systems (macOS and Linux) or a Powershell on Windows. For example, listing the contents of the image directory works like this:

The snippet can contain multiple commands, too. Like this:

Furthermore, it is also possible to assign the output of the command to a page variable using the Bindings: entry field. Enter a variable name and execute the script again. You can then refer to this variable in other snippets.

listing
  

To use a bound page variable in a shell snippet you refer to it like you would with any other shell environment variable.

For example, say we have a Pharo snippet that initializes a string variable:

message := 'It is now {1}' format: { DateAndTime now }
  

Now, we can use that variable in a shell script:

For macOS and Linux (syntax $var)

For Windows (syntax $Env:var)

Note: a variable is only bound as an environment variable for the execution of the shell script when its name is referred to in the script's source code and when the value is transferable (basically a primitive like a string).

The shell snippet can show asynchroneous incremental output that automatically updates. Here is an example.

For macOS and Linux

For WIndows