Skip to content

Instantly share code, notes, and snippets.

@searls
Last active April 28, 2023 16:47
Show Gist options
  • Save searls/4cb712eebc7263f8ae37bace7f51867e to your computer and use it in GitHub Desktop.
Save searls/4cb712eebc7263f8ae37bace7f51867e to your computer and use it in GitHub Desktop.
VS Code 1.77 added the `runCommands` command, which is basically a macro that you can define right in your keybindings file by chaining multiple commands together. In this case I bound individual test runs, file-scoped tests, and full Rake tasks to command-R + modifiers. (The `m` CLI is the m gem, which allows running minitests by file and line)…
[
{
"command": "runCommands",
"key": "cmd-r",
"args": {
"commands": [
"workbench.action.files.save",
"workbench.action.terminal.focus",
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "bundle exec m ${relativeFile}:${lineNumber}\u000D"
}
},
"workbench.action.focusActiveEditorGroup"
]
}
},
{
"command": "runCommands",
"key": "cmd-shift-r",
"args": {
"commands": [
"workbench.action.files.save",
"workbench.action.terminal.focus",
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "bundle exec m ${relativeFile}\u000D"
}
},
"workbench.action.focusActiveEditorGroup"
]
}
},
{
"command": "runCommands",
"key": "cmd-alt-shift-r",
"args": {
"commands": [
"workbench.action.files.save",
"workbench.action.terminal.focus",
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "bundle exec rake\u000D"
}
},
"workbench.action.focusActiveEditorGroup"
]
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment