Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Copilot Terminal DetectionNew to Visual Studio Code? Get it now.
Copilot Terminal Detection

Copilot Terminal Detection

erwinkroon

|
61 installs
| (0) | Free
Automatically detects when GitHub Copilot is controlling the terminal and provides shell integration
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Copilot Terminal Detection

Version Downloads Rating

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.

✨ Features

  • 🔍 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

🚀 Quick Start

1. Install the Extension

Install from the VS Code Marketplace or search for "Copilot Terminal Detection" in VS Code.

2. Install the Oh My Zsh Plugin

# 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

3. Enjoy the Magic! ✨

  • 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

2. Install the Oh My Zsh Plugin

  1. 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/
    
  2. Add the plugin to your ~/.zshrc file:

    plugins=(... copilot-terminal-detection)
    
  3. Reload your shell:

    source ~/.zshrc
    

Usage

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

Custom Prompt

# Add to your ~/.zshrc for custom prompt
if [[ "$COPILOT_AGENT_DETECTED" == "true" ]]; then
    PS1="[🤖] $PS1"

Commands

The extension provides the following commands:

  • Copilot Terminal Detection: Detect Copilot Terminal - Manually detect if the active terminal is from Copilot
  • Copilot Terminal Detection: Create Marker - Manually create a marker file for testing
  • Copilot Terminal Detection: Show Status - Display current marker files and their status

Development

Building

npm run compile

Testing

npm run test

Packaging

npm run package

Configuration

The extension works out of the box with no configuration required. It automatically activates when VS Code starts and begins monitoring terminal creation events.

Environment Variables Set

When a Copilot terminal is detected, the following environment variables are set:

  • IS_AGENT_SESSION=true - Indicates the terminal is controlled by an agent
  • TERMINAL_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.

Technical Details

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

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft