Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Terminal Command TriggerNew to Visual Studio Code? Get it now.
Terminal Command Trigger

Terminal Command Trigger

Ixyri Luyra

|
2 installs
| (0) | Free
Trigger VSCode commands when shell commands are executed. Perfect for auto-restarting clangd before builds.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Terminal Command Trigger

Automatically trigger VSCode commands when terminal commands are executed.

🎯 Use Case

Perfect for solving the clangd + xmake C++ modules issue:

  • clangd memory-maps std.pcm for language support
  • clang compiler cannot access std.pcm when it's memory-mapped
  • This extension auto-restarts clangd before builds to release the file lock

✨ Features

  • 🔍 Auto-detect terminal commands via Shell Integration
  • ⚡ Trigger any VSCode command based on regex patterns
  • 📊 Visual feedback via temporary status bar notifications
  • 🛡️ Smart detection warns if Shell Integration is unavailable

🔧 Configuration

Go to Settings → Extensions → Terminal Command Trigger

Action Syntax

Actions support two formats:

1. VSCode Commands

{
  "onStart": "clangd.restart"
}

2. Extension API Calls

{
  "onStart": "ext:extensionId:api.path"
}

Example:

{
  "onStart": "ext:llvm-vs-code-extensions.vscode-clangd:client.stop"
}

This calls api.client.stop() on the clangd extension.

Complete Example (clangd + xmake)

{
  "terminalCommandTrigger.triggers": [
    {
      "pattern": "^xmake\\b",
      "onStart": "ext:llvm-vs-code-extensions.vscode-clangd:client.stop",
      "onEnd": "ext:llvm-vs-code-extensions.vscode-clangd:client.start",
      "description": "Stop clangd before xmake build, restart after"
    }
  ]
}

How it works:

  1. You run xmake build in terminal
  2. Extension detects it and calls client.stop() → releases std.pcm lock
  3. xmake compiles successfully
  4. Extension calls client.start() → clangd resumes language support

⚠️ Requirements

  • VSCode 1.88+ (Shell Integration API)
  • Supported shells: PowerShell, bash, zsh, fish
  • The extension will warn you once if Shell Integration is not available

🐛 Troubleshooting

"Shell Integration not detected"

Make sure you're using a supported shell:

  • Windows: PowerShell (not cmd.exe)
  • macOS/Linux: bash, zsh, or fish

See VSCode Shell Integration docs

Commands not triggering

  1. Check your regex pattern in settings
  2. Open Output → Terminal Command Trigger for debug logs
  3. Verify the target command exists (e.g., clangd.restart requires clangd extension)

📝 License

MIT

🙏 Credits

Inspired by the real-world pain of C++ modules + clangd development.

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