Skip to content
Use a keyboard shortcut to run any command in the Integrated Terminal of Virtual Studio Code.
TypeScript JavaScript Python Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Run in Terminal, an Extension for vscode

Use a keyboard shortcut to run any command in the Integrated Terminal of Virtual Studio Code.

You can install it from the VSCode Marketplace.

I built this because I wanted something for vscode like benmills' amazing vimux for vim.

The send-to-terminal extension was close to what I wanted, but I wanted to be able to run more than 2 commands per filetype match. run-in-terminal is based on send-to-terminal, but allows an arbitrary number of commands per filetype.

The native Tasks functionality in vscode is also close, but configuration is only possible at the project level, not the global level.

Here is what Run in Terminal looks like:



The simplest way to configure a keybindings.json using the cmd argument for the command:

    "key": "ctrl+e",
    "command": "",
    "args": {"cmd": "/usr/bin/env bash ${relativeFile}", "match": ".*"},
    "when": "resourceLangId == shellscript"
    "key": "ctrl+e",
    "command": "",
    "args": {"cmd": "/usr/bin/env python ${relativeFile}", "match": ".*"},
    "when": "resourceLangId == python"

Note above that when using keybindings.json you might use the 'when' context (rather than the match expression) to specify different commands with the same keybinding for different filetypes. If you do so, use '.*' as your match expression.


If you are using VSCodeVim, things look a little bit different, because there is no support for a 'when' context to perform different commands for different filetypes.


Here is what you might put in your settings.json when configuring with VSCodeVim:

    "vim.normalModeKeyBindingsNonRecursive": [
            "before": ["<leader>", "r", "a"], "after": [],
            "commands": [ {"command": "runInTerminal.runLast" } ]
            "before": ["<leader>", "r", "l"], "after": [],
            "commands": [ {"command": "", "args": {"name": "l"}} ]
            "before": ["<leader>", "r", "b"], "after": [],
            "commands": [ {"command": "", "args": {"name": "b"}} ]
            "before": ["<leader>", "r", "s"], "after": [],
            "commands": [ {"command": "", "args": {"name": "s"}} ]
    "runInTerminal.commands": [
        {"match": "_spec\\.rb$", "name": "l", "cmd": "./bin/rspec ${relativeFile}:${line}"},
        {"match": "_spec\\.rb$", "name": "b", "cmd": "./bin/rspec ${relativeFile}"},
        {"match": "_spec\\.rb$", "name": "s", "cmd": "./bin/rspec"},
        {"match": "(spec|test)\\.js$", "name": "b", "cmd": "xvfb-run ./node_modules/karma/bin/karma start --single-run=true --single-file=\"${relativeFile}\""}

Note above, you specify each keybinding in your vim settings only once with a target name, and then in your runInTerminal.commands, you can specify multiple commands with the same name but different file match expressions. In this case, <leader> r b maps to the name 'b', which has a command for ruby and for javascript.


    "runInTerminal.clearBeforeRun": false, // defaults false

Substitution Tokens

You can use the following substitution tokens in cmd strings:

  • ${column}
  • ${cwd}
  • ${env.Name} (replace environment variables)
  • ${file}
  • ${fileBasename}
  • ${fileBasenameNoExt}
  • ${fileDirname}
  • ${fileExtname}
  • ${line}
  • ${relativeFile}
  • ${workspaceRoot}


You should provide an object as the value of the arguments key when calling this command. This object must have either (i) a name pointing to a command in runInTerminal.commands or (ii) a file match expression and cmd to execute.


    "command": "",
    "args": {"name": "focused"},


    "command": "",
    "args": {"match": "\\.py$", "cmd": "/usr/bin/env python ${relativeFile}"},


Runs the last cmd run by again.

Known Issues

  • The ${relativeFile} substitution token only works when you have opened an entire folder with vscode, not a single file.
  • Unknown behavior when many commands in 'runInTerminal.commands' match both the match expression and name of the command run.

Development and Release

To create a new release,

# bump version number in package.json
npm run vpackage # package the release, creates ,vsix
npm run vpublish # publish to store, see
# Will prompt for Azure Devops Personal Access Token, get fresh one at:
# On "Error: Failed Request: Unauthorized(401)"
# see:
# The reason for returning 401 was that I didn't set the Accounts setting to all accessible accounts.
You can’t perform that action at this time.