Related: ‣
Install the multi-command VSCode extension
Add to .vscode/settings.json a multiCommand.commands array. This is your per-project config.
Basically you’d chain workbench.action.terminal commands: new → renameWithArg → sendSequence (with a trailing /n if you want to have the command run straight away)
Example .vscode/settings.json:
{
"multiCommand.commands": [
{
"command": "Full Dev Stack",
"sequence": [
{
"command": "workbench.action.terminal.new",
"args": {}
},
{
"command": "workbench.action.terminal.renameWithArg",
"args": {
"name": "server:dev"
}
},
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "npm run server:dev\n"
}
},
{
"command": "workbench.action.terminal.new",
"args": {}
},
{
"command": "workbench.action.terminal.renameWithArg",
"args": {
"name": "client:dev"
}
},
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "npm run client:dev\n"
}
},
{
"command": "workbench.action.terminal.new",
"args": {}
},
{
"command": "workbench.action.terminal.renameWithArg",
"args": {
"name": "test:api"
}
},
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "npm run test:api"
}
},
{
"command": "workbench.action.terminal.new",
"args": {}
},
{
"command": "workbench.action.terminal.renameWithArg",
"args": {
"name": "test:client"
}
},
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "npm run test:client"
}
},
{
"command": "workbench.action.terminal.new",
"args": {}
},
{
"command": "workbench.action.terminal.renameWithArg",
"args": {
"name": "misc"
}
},
]
}]
}
Note that some commands in sendSequence end with /n and others do not. The trailing /n makes the command run straight away. Sometimes you may want to omit it, so that you have a terminal with a command that’s ready to run when you choose.
Use the VS Code Command Palette and run “Preferences: Open Keyboard Shortcuts (JSON)”. On Mac that file lives at ~/Library/Application Support/Code/User/keybindings.json.
Add the following lines in your file:
// Place your key bindings in this file to override the defaults
[
{
"key": "cmd+k cmd+k",
"command": "extension.multiCommand.execute",
"args": "multiCommand.openTerminalsAndRunScripts",
"when": "editorTextFocus"
}
]
Now you can hold CMD and press k twice and that will prompt you for the multi-command config you want (you can configure multiple).
Alternative: “cmd+; cmd+;” is good if you’re using ‣ to avoid the conflict with cmd+k. I set my VS Code shortcut to that as well to avoid confusion if / when I switch between Code and Cursor.
Or use whatever other keyboard shortcut you like.
Happy coding! 🧑💻