- What is cmd exec
- How to setup cmd exec
- Full Configuration Sample
- Usage
- Use a different shell
- Contributing
Run command line scripts (with parameters) directly from #VSCode with a configured form. Create and customize your own commands to simplify your way of working.
Follow the instructions How to setup cmd exec to use this extension.
- Use
ctrl+shift+P
orF1
to invoke the Command Palette - Type
Preferences: Open Settings (JSON)
- Add/copy basic configuration to
settings.json
"script-runner.statusBar" : false, "script-runner.definitions": { "commands": [ ], "variables": { } }
- Add command definitions to
commands
Sample command definition:
{ "identifier": "test", "description": "Test Runner", "command": "echo $var1 $var2", "working_directory": "./", "form": [ { "variable": "$var1", "question": "What is $var1?", "default": "Test 1" }, { "variable": "$var2", "question": "What is $var2?", "options": ["Option 1", "Option 2", "Option 3"] } ] }
- Define variables for all command definitions in
variables
"variables": { "$tmp": "./" }
Name | Description | Required | Type |
---|---|---|---|
identifier | Identifier used to do key binding. Use alphanumerical and hyphen/underscore only. | yes | string |
description | Description of the command. | yes | string |
command | Command to execute (with variables). | yes | string |
working_directory | The working directory in which to execute the script. | string | |
form | A list of questions to ask in order to obtain values for variables. | array | |
variable | The variable name. | string | |
question | The question to ask the user. | string | |
password | Input is a password. Default is false. Suggestion: use also show_in_console: false | boolean | |
default | The default value to put in the field. Only for text inputs. | string | |
defaultValuePath | Overrides the default value with the current file path. Empty if no file open. password option ignored | boolean | |
defaultValueFilename | Overrides the default value with the current filename. Empty if no file open. password option ignored | boolean | |
options | List of options (string) | array | |
variables | List of variables (string) | array |
"script-runner.statusBar": true, "script-runner.definitions": { "commands": [ { "identifier": "test", "description": "Test Runner 1", "command": "echo $var1 $var2", "working_directory": "$tmp", "form": [ { "variable": "$var1", "question": "What is $var1?", "default": "Test 1" }, { "variable": "$var2", "question": "What is $var2?", "options": [ "Option 1", "Option 2", "Option 3" ] } ] }, { "identifier": "test2", "description": "Test Runner 2", "command": "echo $var1 ", "working_directory": "$tmp", "form": [ { "variable": "$var1", "question": "What is $var1?", "default": "Test 1" } ] }, { "identifier": "filepath1", "description": "Filepath", "command": "echo $path ", "working_directory": "$tmp", "form": [ { "variable": "$path", "question": "What is the path", "defaultValuePath": true } ] } ], "variables": { "$tmp": "./" } }
- Use
ctrl+shift+P
orF1
to invoke the Command Palette. - Type
Script Runner: Run
. - Your list of commands will appear, you can then select the one to execute.
- If your command has a form, the questions will be displayed.
- The command will be executed.
If you enable the statusbar item, it will be placed at the right corner of the bottom status bar.
"script-runner.statusBar" : true,
You can bind a keyboard shortcut to the command. Keyboard Shortcuts script-runner.$command_identifier$
.
"script-runner.customShell.enabled": true, "script-runner.customShell.path": "/bin/sh",
File bugs, feature requests in Github Issues.
Leave a review on Visual Studio Marketplace.