The missing piece for GitHub Copilot's terminal execution. Run multi-line scripts reliably with proper output capture, pager bypass, and cross-shell support.
GitHub Copilot's built-in run_in_terminal tool has limitations that cause frustration:
# When run_in_terminal executes this:
echo "Line 1"
echo "Line 2"
echo "Line 3"The terminal runs the entire script, but only the first line's output is returned to the AI agent. The agent thinks "Line 1" is all that happened and misses everything else.
Commands like gcloud --help, kubectl describe, or git log open interactive pagers (less, more) that hang forever waiting for user input.
Error streams, warnings, and verbose output often don't make it back to the AI agent.
Copilot Script Runner solves all of these by:
- ✅ Writing scripts to temp files — No parsing or escaping issues
- ✅ Merging all output streams — Errors, warnings, and stdout all captured
- ✅ Bypassing pagers automatically —
gcloud --helpworks without hanging - ✅ Supporting multiple shells — PowerShell, WSL, and Git Bash
Install the extension, then in GitHub Copilot Chat:
Use #runScript to check my gcloud configuration
Use #runScript with shell="wsl" to run a Linux deployment script
Use #runScript with shell="bash" to run commands on this Linux remote
The AI agent will use the appropriate shell to execute your commands reliably.
Executes scripts with full stream capture. Supports multiple shells via the shell parameter:
| Shell | Description |
|---|---|
powershell |
PowerShell (default on Windows) |
bash |
Native Bash (Linux/macOS/Remote SSH) |
wsl |
Windows Subsystem for Linux |
gitbash |
Git Bash on Windows |
zsh |
Z shell |
fish |
Fish shell |
PowerShell Example:
# Works perfectly:
gcloud projects list
kubectl get pods --all-namespaces
git log --oneline -20
# Complex multi-line scripts:
$services = Get-Service | Where-Object Status -eq 'Running'
foreach ($svc in $services) {
Write-Host "$($svc.Name): $($svc.Status)"
}Bash Example (via WSL, Git Bash, or native):
# Works on any platform:
uname -a
docker ps
kubectl apply -f manifests/
# Git operations:
git status
git log --oneline -10wsl— Windows Subsystem for Linuxgitbash— Git Bash on Windows
Returns the currently installed version of the extension. Useful for debugging.
Use #scriptRunnerVersion to check the installed version
Retrieves output from a Script Runner terminal by its ID. Essential for checking results of background processes.
Use #getScriptOutput with id="a8cc5ce0" to check the server output
Note: This tool uses Script Runner's terminal IDs (returned by
#runScript), not VS Code's built-in terminal IDs.
| Parameter | Type | Default | Description |
|---|---|---|---|
script |
string | required | The script to execute |
shell |
"powershell" | "bash" | "wsl" | "gitbash" | "zsh" | "fish" |
"powershell" |
Which shell to use |
isBackground |
boolean | false |
Return immediately for long-running processes |
timeoutMs |
number | — | Timeout in milliseconds |
keepScript |
boolean | false |
Keep the temp file for debugging |
workingDirectory |
string | cwd | Directory to run the script in |
For long-running commands like servers or watch tasks, use background mode:
Use #runScript with isBackground=true to start the dev server
The tool returns immediately with a Terminal ID. The process continues running in the VS Code terminal, and you can check output later using VS Code's get_terminal_output tool with the returned ID.
The extension intelligently manages terminals:
- Reuses idle terminals — Avoids spawning a new terminal for every command
- Names terminals by shell type — e.g., "Script Runner (pwsh)", "Script Runner (wsl)"
- Returns Terminal ID — Every execution returns a unique ID for tracking
- Cleans up automatically — Temp script files are deleted after execution (unless
keepScript=true)
The extension works with VS Code Remote SSH:
Use #runScript with shell="bash" to run commands on the remote server
When connected to a remote host:
- Scripts are written to the remote temp directory
- Bash executes on the remote server
- Output is captured and returned to the agent
Recommended shell settings for remote:
| Platform | Shell Parameter |
|---|---|
| Linux remote | shell="bash" |
| macOS remote | shell="bash" or shell="zsh" |
| Windows remote with WSL | shell="wsl" |
| Windows remote with Git Bash | shell="gitbash" |
flowchart LR
A["Copilot Agent\nsends script"] --> B["Script Runner\nwrites to temp file"]
B --> C["VS Code Terminal\n(shell integration)"]
C --> D["Output streams\nmerged & piped"]
D --> E["Agent receives\nclean output"]
PowerShell: Commands are wrapped with *>&1 | Out-Host to:
- Merge all 6 PowerShell streams into stdout
- Stream output in real-time (no buffering)
- Allow progress bars and Write-Progress to display correctly
WSL: Commands run inside wsl bash -c '...' to ensure:
- Proper path translation (Windows → Linux)
- Correct redirection (
2>&1happens in Bash, not PowerShell)
Git Bash: Uses $env:ProgramFiles\Git\bin\bash.exe with similar wrapping.
- VS Code 1.100.0 or higher
- GitHub Copilot extension
- For Bash scripts: WSL or Git Bash installed
- Open VS Code
- Press
Ctrl+Shift+Xto open Extensions - Search for "Copilot Script Runner"
- Click Install
- Open Extensions
- Search for "Copilot Script Runner" by bdayadev
- Click Install
The extension requires VS Code's shell integration feature. Make sure:
- You're using a supported shell (PowerShell 7+, Bash, Zsh)
- Shell integration is enabled in VS Code settings
Install Windows Subsystem for Linux:
wsl --installInstall Git for Windows which includes Git Bash.
This is normal for colored output. The raw terminal codes are preserved. Future versions may add an option to strip ANSI codes.
Contributions welcome!
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a Pull Request
MIT License — see LICENSE for details.
This extension addresses problems documented in these VS Code GitHub issues:
| Issue | Title | Reactions |
|---|---|---|
| #253265 | Agent/Chat extension cannot see terminal command output | 👍 19 |
| #282904 | Copilot misses last lines of output (Git Bash + WSL) | — |
| #259328 | run_in_terminal fails to capture output (Windows) | 👍 1 |
| #261691 | run_in_terminal fails to capture stdout from CLI tools | — |
| #261585 | GitHub Copilot Chat Not Capturing Terminal Output | 👍 2 |
| #252524 | Copilot agent can't see run_in_terminal output (WSL) | — |
| #269724 | Terminal output capture drops last line (Cygwin) | 👍 1 |
| #273753 | Terminal stuck after pager (less) | — |
If you're experiencing any of these issues, Copilot Script Runner provides a reliable workaround by writing scripts to temp files and using VS Code's shell integration for proper output capture.
Made with ❤️ by Bdaya Dev