A VS Code extension that automatically detects when GitHub Copilot is controlling the terminal and provides seamless shell integration through an Oh My Zsh plugin.
- 🔍 Automatic Detection: Instantly detects when terminals are opened by Copilot agents
- 🎯 Per-Terminal Precision: Each terminal is independently detected (not global)
- 🐚 Oh My Zsh Integration: Easy setup with a custom Oh My Zsh plugin
- ⚡ Environment Variables: Sets
COPILOT_AGENT_DETECTED
for shell customization - 🛡️ Safe Operation: Won't break if the extension isn't loaded
- 🎨 Customizable: Modify prompts, aliases, and behavior per terminal type
Install from the VS Code Marketplace or search for "Copilot Terminal Detection" in VS Code.
# Copy the plugin to your Oh My Zsh directory
mkdir -p ~/.oh-my-zsh/custom/plugins/copilot-terminal-detection
cp oh-my-zsh-plugin/copilot-terminal-detection.plugin.zsh ~/.oh-my-zsh/custom/plugins/copilot-terminal-detection/
# Add to your ~/.zshrc
plugins=(... copilot-terminal-detection)
# Reload your shell
source ~/.zshrc
- Open a Copilot terminal → See
🤖
indicators - Open a regular terminal → Normal behavior
- Customize your experience with the environment variable
Install the extension from the VS Code marketplace or package it locally:
npm install
npm run compile
npx vsce package
code --install-extension copilot-terminal-detection-*.vsix
-
Copy the plugin to your Oh My Zsh custom plugins directory:
mkdir -p ~/.oh-my-zsh/custom/plugins/copilot-terminal-detection cp oh-my-zsh-plugin/copilot-terminal-detection.plugin.zsh ~/.oh-my-zsh/custom/plugins/copilot-terminal-detection/
-
Add the plugin to your
~/.zshrc
file:plugins=(... copilot-terminal-detection)
-
Reload your shell:
source ~/.zshrc
The plugin automatically sets the COPILOT_AGENT_DETECTED
environment variable:
# Check if running in a Copilot terminal
if [[ "$COPILOT_AGENT_DETECTED" == "true" ]]; then
echo "🤖 This is a Copilot-controlled terminal"
else
echo "💻 This is a regular terminal"
fi
# Add to your ~/.zshrc for custom prompt
if [[ "$COPILOT_AGENT_DETECTED" == "true" ]]; then
PS1="[🤖] $PS1"
The extension provides the following commands:
Copilot Terminal Detection: Detect Copilot Terminal
- Manually detect if the active terminal is from CopilotCopilot Terminal Detection: Create Marker
- Manually create a marker file for testingCopilot Terminal Detection: Show Status
- Display current marker files and their status
npm run compile
npm run test
npm run package
The extension works out of the box with no configuration required. It automatically activates when VS Code starts and begins monitoring terminal creation events.
When a Copilot terminal is detected, the following environment variables are set:
IS_AGENT_SESSION=true
- Indicates the terminal is controlled by an agentTERMINAL_MODE=agent
- Specifies the terminal mode as agent-controlled
These variables are available to shell scripts and can be used to modify shell behavior, prompts, or other terminal-related functionality.
The extension uses:
- VS Code's
window.onDidOpenTerminal
event to monitor terminal creation GlobalEnvironmentVariableCollection
API to set environment variables- Terminal name and creation option analysis for detection
- WeakSet to track Copilot terminals for cleanup
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit issues and pull requests.