packages/kilo-docs/pages/automate/extending/shell-integration.md
Terminal Shell Integration is a key feature that enables Kilo Code to execute commands in your terminal and intelligently process their output. This bidirectional communication between the AI and your development environment unlocks powerful automation capabilities.
{% tabs %} {% tab label="VSCode (Legacy)" %}
Shell integration is automatically enabled in Kilo Code and connects directly to your terminal's command execution lifecycle without requiring any setup from you. This built-in feature allows Kilo Code to:
execute_command toolWhen Kilo Code needs to perform tasks like installing dependencies, starting a development server, or analyzing build errors, shell integration works behind the scenes to make these interactions smooth and effective.
Shell integration is built into Kilo Code and works automatically in most cases. If you see "Shell Integration Unavailable" messages or experience issues with command execution, try these solutions:
Ctrl+Shift+P or Cmd+Shift+P) → "Terminal: Select Default Profile" → Choose bash, zsh, PowerShell, or fishSet-ExecutionPolicy RemoteSigned -Scope CurrentUser then restart VS Code. "$(code --locate-shell-integration-path bash)" to your ~/.bashrcKilo Code provides several settings to fine-tune shell integration. Access these in the Kilo Code panel under Settings → Terminal.
{% image src="/docs/img/shell-integration/terminal-output-limit.png" alt="Terminal output limit slider set to 500" width="500" caption="Terminal output limit slider set to 500" /%} Controls the maximum number of lines captured from terminal output. When exceeded, it keeps 20% of the beginning and 80% of the end with a truncation message in between. This prevents excessive token usage while maintaining context. Default: 500 lines.
{% image src="/docs/img/shell-integration/shell-integration-timeout.png" alt="Terminal shell integration timeout slider set to 15s" width="500" caption="Terminal shell integration timeout slider set to 15s" /%}
Maximum time to wait for shell integration to initialize before executing commands. Increase this value if you experience "Shell Integration Unavailable" errors. Default: 15 seconds.
{% image src="/docs/img/shell-integration/terminal-command-delay.png" alt="Terminal command delay slider set to 0ms" width="500" caption="Terminal command delay slider set to 0ms" /%}
Adds a small pause after running commands to help Kilo Code capture all output correctly. This setting can significantly impact shell integration reliability due to VSCode's implementation of terminal integration across different operating systems and shell configurations:
{% callout type="info" title="Important" %} Terminal restart required for these settings
Changes to advanced terminal settings only take effect after restarting your terminals. To restart a terminal:
Always restart all open terminals after changing any of these settings. {% /callout %}
{% image src="/docs/img/shell-integration/power-shell-workaround.png" alt="PowerShell counter workaround checkbox" width="600" caption="PowerShell counter workaround checkbox" /%}
Helps PowerShell run the same command multiple times in a row. Enable this if you notice Kilo Code can't run identical commands consecutively in PowerShell.
{% image src="/docs/img/shell-integration/clear-zsh-eol-mark.png" alt="Clear ZSH EOL mark checkbox" width="600" caption="Clear ZSH EOL mark checkbox" /%}
Prevents ZSH from adding special characters at the end of output lines that can confuse Kilo Code when reading terminal results.
{% image src="/docs/img/shell-integration/oh-my-zsh.png" alt="Enable Oh My Zsh integration checkbox" width="600" caption="Enable Oh My Zsh integration checkbox" /%}
Makes Kilo Code work better with the popular Oh My Zsh shell customization framework. Turn this on if you use Oh My Zsh and experience terminal issues.
{% image src="/docs/img/shell-integration/power10k.png" alt="Enable Powerlevel10k integration checkbox" width="600" caption="Enable Powerlevel10k integration checkbox" /%}
Improves compatibility if you use the Powerlevel10k theme for ZSH. Turn this on if your fancy terminal prompt causes issues with Kilo Code.
{% image src="/docs/img/shell-integration/zdotdir.png" alt="Enable ZDOTDIR handling checkbox" width="600" caption="Enable ZDOTDIR handling checkbox" /%}
Helps Kilo Code work with custom ZSH configurations without interfering with your personal shell settings and customizations.
PowerShell restricts script execution by default. To configure:
Get-ExecutionPolicySet-ExecutionPolicy RemoteSigned -Scope CurrentUserCommon policies:
Restricted: No scripts allowed (default)RemoteSigned: Local scripts can run; downloaded scripts need signingUnrestricted: All scripts run with warningsAllSigned: All scripts must be signedIf automatic integration fails, add the appropriate line to your shell configuration:
Bash (~/.bashrc):
[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path bash)"
Zsh (~/.zshrc):
[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path zsh)"
PowerShell ($Profile):
if ($env:TERM_PROGRAM -eq "vscode") { . "$(code --locate-shell-integration-path pwsh)" }
Fish (~/.config/fish/config.fish):
string match -q "$TERM_PROGRAM" "vscode"; and . (code --locate-shell-integration-path fish)
If you use terminal customization tools:
Powerlevel10k:
# Add before sourcing powerlevel10k in ~/.zshrc
typeset -g POWERLEVEL9K_TERM_SHELL_INTEGRATION=true
Alternative: Enable the Powerlevel10k Integration setting in Kilo Code.
Confirm shell integration is active with these commands:
Bash:
set | grep -i '[16]33;'
echo "$PROMPT_COMMAND" | grep vsc
trap -p DEBUG | grep vsc
Zsh:
functions | grep -i vsc
typeset -p precmd_functions preexec_functions
PowerShell:
Get-Command -Name "*VSC*" -CommandType Function
Get-Content Function:\Prompt | Select-String "VSCode"
Fish:
functions | grep -i vsc
functions fish_prompt | grep -i vsc
Visual indicators of active shell integration:
When using Windows Subsystem for Linux (WSL), there are two distinct ways to use VSCode with WSL, each with different implications for shell integration:
In this setup:
source "$(code --locate-shell-integration-path <shell>)" is loaded for your shell within the WSL environment because it may not get automatically loaded; see above.In this setup:
code .For optimal shell integration with WSL, we recommend:
code .If you use Fish in Cygwin, a minimal setup is usually enough:
In your Cygwin Fish config (~/.config/fish/config.fish), add:
string match -q "$TERM_PROGRAM" "vscode"; and . (code --locate-shell-integration-path fish)
Configure a terminal profile in VS Code that launches Fish (directly or via Cygwin bash).
Restart VS Code and open a new terminal to verify integration.
{% image src="/docs/img/shell-integration/shell-integration-8.png" alt="Fish Cygwin Integration Example" width="600" caption="Fish Cygwin Integration Example" /%}
Issue: After VS Code updates beyond version 1.98, shell integration may fail with the error "VSCE output start escape sequence (]633;C or ]133;C) not received".
Solutions:
Set Terminal Command Delay:
Roll Back VS Code Version:
WSL-Specific Workaround:
code .ZSH Users:
Issue: If text is already typed in the terminal when Kilo Code tries to run a command, Kilo Code will press Ctrl+C first to clear the line, which can interrupt running processes.
Workaround: Make sure your terminal prompt is empty (no partial commands typed) before asking Kilo Code to execute terminal commands.
Issue: Commands that span multiple lines can confuse Kilo Code and may show output from previous commands mixed in with current output.
Workaround: Instead of multi-line commands, use command chaining with && to keep everything on one line (e.g., echo a && echo b instead of typing each command on a separate line).
Workaround: Enable the "PowerShell counter workaround" setting and set a terminal command delay of 150ms in the settings to give commands more time to complete.
Issue: Sometimes VS Code doesn't show or capture all the output from a command.
Workaround: If you notice missing output, try closing and reopening the terminal tab, then run the command again. This refreshes the terminal connection.
When shell integration issues occur, check the debug logs:
[Terminal Process]preOutput content in error messages:
'') means VS Code sent no dataThe VS Code Terminal Integration Test Extension helps diagnose shell integration issues by testing different settings combinations:
When Commands Stall:
Testing Settings:
Reporting Issues:
{% /tab %} {% tab label="VSCode & CLI" %}
The new CLI and extension take a fundamentally different approach to shell execution. Instead of relying on VS Code's terminal shell integration, the CLI spawns and manages shell processes directly using the bash tool.
This means:
bash ToolThe bash tool is the primary way the agent executes shell commands. It spawns a persistent shell session and runs commands within it.
workdir parameter to run commands in a specific directory, instead of cd <dir> && <command> patternsCommands are parsed using Tree-sitter before execution, enabling:
The CLI automatically detects the appropriate shell for your platform using Shell.acceptable(). This selects a compatible shell (bash, zsh, etc.) without requiring manual configuration.
When using the Kilo Code VS Code extension with the Agent Manager, each agent session gets its own dedicated VS Code terminal.
Agent: {branch}, where {branch} is the git branch or worktree the session is working in| Shortcut | Action |
|---|---|
| <kbd>Cmd</kbd>+<kbd>/</kbd> | Focus the session's terminal |
| <kbd>Cmd</kbd>+<kbd>.</kbd> | Cycle agent mode |
Right-click in an Agent Manager terminal to access these actions:
Shell execution in the new CLI is significantly simpler than the VSCode version's terminal integration. Most issues are resolved by ensuring:
If commands fail to execute, check the CLI's log output for error details. The CLI logs the shell it detected and any errors during command execution.
{% /tab %} {% /tabs %}
If you've followed these steps and are still experiencing problems, please:
For additional help, join our Discord.