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: false
Command 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: 50
Command with custom terminal ID
{ "action": "executeTerminalCommand", "command": "echo 'Hello, world!'", "terminalId": "demo-terminal"}
action: executeTerminalCommandcommand: "echo 'Hello, world!'"terminalId: demo-terminal
Execute 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.}
action: executeScriptid: <script id>path: <script to execute>command: node # Can be powershell, bash, shell, python, etc.
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.json
console.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: closeTerminal
Close a specific terminal by ID
{ "action": "closeTerminal", "terminalId": "demo-terminal"}
action: closeTerminalterminalId: demo-terminal