Terminal actions
Terminal actions are used to perform actions related to the terminal in the editor. You can use these actions to run commands, clear the terminal, and more.
Open the terminal
Open the terminal in the editor. You can optionally specify a terminal ID to open a specific terminal.
{ "action": "openTerminal", "terminalId": "<terminal id (optional)>"}action: openTerminalterminalId: <terminal id (optional)>Execute a terminal command
Execute a terminal command in the terminal.
{ "action": "executeTerminalCommand", "command": "<command to execute>", "terminalId": "<terminal id (optional)>", "autoExecute": "<true/false (optional - default is true)>", "insertTypingMode": "<typing mode (optional - default is 'instant')>", "insertTypingSpeed": "<speed in milliseconds (optional)>"}action: executeTerminalCommandcommand: <command to execute>terminalId: <terminal id (optional)>autoExecute: <true/false (optional - default is true)>insertTypingMode: <typing mode (optional - default is 'instant')>insertTypingSpeed: <speed in milliseconds (optional)>Properties
- command: The command to execute in the terminal
- terminalId: Optional. Define a custom name for the terminal. Default is “DemoTime”
- autoExecute: Optional. Whether to automatically execute the command after typing it. Default behavior varies
- insertTypingMode: Optional. How the command should be typed. Options:
instant: Types the command instantlycharacter-by-character: Types each character individually
- insertTypingSpeed: Optional. Speed in milliseconds between each typing unit.
Examples
Basic terminal command
{ "action": "executeTerminalCommand", "command": "echo 'Hello, world!'"}action: executeTerminalCommandcommand: "echo 'Hello, world!'"Manually execute command
{ "action": "executeTerminalCommand", "command": "echo 'Hello, world!'", "autoExecute": false}action: executeTerminalCommandcommand: "echo 'Hello, world!'"autoExecute: falseCommand with character-by-character typing
{ "action": "executeTerminalCommand", "command": "echo 'Hello, world!'", "insertTypingMode": "character-by-character", "insertTypingSpeed": 50, "insertTypingSpeed": 100}action: executeTerminalCommandcommand: "echo 'Hello, world!'"insertTypingMode: character-by-characterinsertTypingSpeed: 50Command with custom terminal ID
{ "action": "executeTerminalCommand", "command": "echo 'Hello, world!'", "terminalId": "demo-terminal"}action: executeTerminalCommandcommand: "echo 'Hello, world!'"terminalId: demo-terminalExecute a script in the background
Execute a script in the background of which you can use the output in the next steps.
{ "action": "executeScript", "id": "<script id>", "path": "<script to execute>", "command": "node", // Can be powershell, bash, shell, python, etc. "args": ["arg1", "arg2"] // Optional}action: executeScriptid: <script id>path: <script to execute>command: node # Can be powershell, bash, shell, python, etc.args: # Optional - arg1 - arg2Passing arguments to scripts
You can pass arguments to your scripts using the args property. Arguments are provided as an array of strings that are passed as positional command-line arguments to the script in the order specified.
Accessing arguments in different languages
// Arguments are available in process.argv starting at index 2const args = process.argv.slice(2);console.log('First arg:', args[0]); // "30" (age)console.log('Second arg:', args[1]); // "John" (name)
// Or destructure directlyconst [age, name] = process.argv.slice(2First argumentconsole.log('Second arg:', args[1]); // Second argument
// Or destructure directlyconst [firstArg, secondArg] = process.argv.slice(2);console.log(`First: ${firstArg}, Second: ${secondArg
```python title="script.py"import sys
# Arguments are available in sys.argv starting at index 1args = sys.argv[1:]print(f'First arg: {args[0]}') # First argumentprint(f'Second arg: {args[1]}') # Second argument
# Or unpack directlyfirst_arg, second_arg = sys.argv[1:3]print(f'First: {first_arg}, Second: {second_arg}')#!/bin/bash
# Arguments are available as $1, $2, etc.echo "First arg: $1" # First argumentecho "Second arg: $2" # Second argument
# Or use positional parametersfirst_arg=$1second_arg=$2echo "First: $first_arg, Second: $second_arg"Complete example with arguments
{ "title": "Script with arguments example", "description": "Passing arguments to a script", "steps": [ { "action": "executeScript", "id": "greeting", "path": "greet.mjs", "command": "node", "args": ["Alice", "25"] }, { "action": "create", "path": "result.txt", "content": "{SCRIPT_greeting}" } ]}title: Script with arguments exampledescription: Passing arguments to a scriptsteps: - action: executeScript id: greeting path: greet.mjs command: node args: - Alice - "25" - action: create path: result.txt content: "{SCRIPT_greeting}"const [name, age] = process.argv.slice(2);console.log(`Hello ${name}, you are ${age} years old!`);This will execute: node greet.mjs "Alice" "25" and output: Hello Alice, you are 25 years old!
Example of using the output of a script
{ "title": "Script example", "description": "", "steps": [ { "action": "executeScript", "id": "firstName", "path": "writeFirstName.mjs", "command": "node" }, { "action": "create", "path": "sample.json", "content": "{\\n \\"firstName\\": \\"{SCRIPT_firstName}\\"\\n}" }, { "action": "open", "path": "sample.json" } ]}title: Script exampledescription: ""steps: - action: executeScript id: firstName path: writeFirstName.mjs command: node - action: create path: sample.json content: "{\\n \\"firstName\\": \\"{SCRIPT_firstName}\\"\\n}" - action: open path: sample.jsonconsole.log('Elio');Close a terminal
Close the terminal. You can optionally specify a terminal ID to close a specific terminal.
{ "action": "closeTerminal", "terminalId": "<terminal id (optional)>"}action: closeTerminalterminalId: <terminal id (optional)>Examples
Close the default terminal
{ "action": "closeTerminal"}action: closeTerminalClose a specific terminal by ID
{ "action": "closeTerminal", "terminalId": "demo-terminal"}action: closeTerminalterminalId: demo-terminal