Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Shell RunNew to Visual Studio Code? Get it now.
Shell Run

Shell Run

Zlatko Bratkovic

|
513 installs
| (0) | Free
Execute shell scripts (.sh, .bat, .cmd, .ps1) from context menu, CodeLens, or right-click in their folder
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Shell Run

Source available at github.com/oktalz/shell-run.

Run shell scripts directly from VS Code — right-click in the explorer, right-click in the editor, or click the CodeLens links above the first line.

Supported file types

Extension Runner
.sh sh / bash / shebang (see Interpreter)
.bat, .cmd cmd /c
.ps1 powershell -ExecutionPolicy Bypass -File

Scripts always run with their containing folder as the working directory.

Running a script

CodeLens (inside the editor)

When a supported script file is open, two clickable links appear above line 1:

▶ Run  ▶ Run with Args

Context menu

Right-click a supported file in the Explorer or inside the Editor:

  • Run: Execute — run with no arguments
  • Run: Execute with Args — open an input box, then run with the provided arguments

Arguments are passed to the script verbatim, so the shell parses quotes and flags exactly as typed (e.g. --name "John Doe" --dry-run).

Status bar

When a supported script file is the active editor, a ▶ Run button appears in the status bar (bottom-right). Click it to run the current script with no arguments.

Output

Where output appears is controlled by the shell-run.outputType setting (default: notification):

Value Behaviour
tab Reuse a single shell-run tab, streaming output live as the script runs
newTab Open a new plain-text tab for each run (shown when the script finishes)
outputChannel Append to the Shell Run Output panel, streaming output live
notification Show a VS Code notification (truncated at 500 characters)
terminal Run in the integrated terminal (process stays alive)

tab and outputChannel update line-by-line while the script runs, so you see progress immediately. newTab and notification are one-shot and render once the script exits.

Per-script directives

Add a directive anywhere in the first 3 lines of the script to override settings for that file. The form is shell-run:<key>:<value>:

Directive Effect
shell-run:output:<type> Override outputType (tab, newTab, outputChannel, notification, terminal)
shell-run:interpreter:<bin> Run a .sh script with this interpreter (e.g. zsh), overriding the setting and shebang
shell-run:cwd:<path> Run with this working directory instead of the script's folder. Relative paths resolve against the script's folder; absolute paths are used as-is
shell-run:args:<args> Default arguments always passed to the script. Any arguments entered via Run with Args are added in front of these
# shell-run:output:outputChannel
# shell-run:args:--env prod
# shell-run:cwd:../build
rem shell-run:output:newTab

The interpreter directive applies to .sh files only (.bat/.cmd always use cmd, .ps1 always uses powershell):

# shell-run:interpreter:zsh

Directive lines are automatically stripped from the displayed output.

Autocomplete

While editing a directive in the first 3 lines of a script, IntelliSense suggests:

  • the directive keys after you type shell-run:,
  • output types after shell-run:output:,
  • common interpreters after shell-run:interpreter: (.sh files only),
  • folder paths (relative to the script) after shell-run:cwd:.

Settings

Setting Default Description
shell-run.outputType notification Where to display script output
shell-run.interpreter auto Shell to use for .sh files
shell-run.showScriptInfo false Prepend the command and working directory to the output

Interpreter

Applies to .sh files only.

Value Behaviour
auto Read the shebang (#!) from line 1; fall back to sh if absent
sh Always use sh
bash Always use bash

Examples detected by auto:

#!/bin/bash          →  bash
#!/usr/bin/env zsh   →  zsh
#!/bin/sh            →  sh
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft