A Visual Studio Code extension that plays custom sound alerts when a terminal command finishes executing, depending on the execution result.
Features
Detects when a terminal command finishes executing.
Captures and analyzes the terminal output using the modernized shell execution VS Code API.
Plays different sounds for:
Success: Plays success.mp3 when execution finishes normally.
Runtime Error: Plays error.mp3 when keywords such as "error", "exception", or "failed" are detected, or the process exits with a non-zero code.
Compile Error: Plays compile.mp3 when compilation errors are found (e.g., "compilation error", "syntax error").
Visual Notifications: Shows a notification message along with the sound whenever a run is complete.
Highly Configureable: Enable/disable sounds or assign custom audio file paths right in the VS Code Settings!
Requirements
VS Code version 1.86.0 or higher.
Node.js installed to build the extension from source.
An OS audio player. By default, play-sound uses built in OS audio capabilities (like native Windows scripts or Mac's afplay).
Extension Settings
You can configure the extension through VS Code settings via File > Preferences > Settings:
codeSound.enable: Enable or disable the sound alerts. (Default: true)
codeSound.successSound: Path to the success sound file.
codeSound.errorSound: Path to the runtime error sound file.
codeSound.compileSound: Path to the compile error sound file.
Paths can be absolute strings leading to anywhere on your disk, or relative to the extension folder if you replace the bundled sounds.
🚀 Getting Started
If you want to run or modify this extension locally:
1. Install Dependencies
Open a terminal in the folder where you created this project (code-execution-sound-alert) and run:
npm install
2. Add Sound Files
To keep the zip sizes small and respect licensing, this template comes with dummy placeholder files. You MUST replace them with your actual sound files!
Add your actual .mp3 files exactly where the dummies are in the sounds/ directory:
sounds/success.mp3
sounds/error.mp3
sounds/compile.mp3
3. Run the Extension locally (F5)
Open this code-execution-sound-alert folder deeply inside VS Code.
Press F5 on your keyboard to start debugging.
A new Extension Development Host window will pop up.
Try running a command that causes an error in your terminal or executes fine (e.g. node -e "throw new Error('boom')") to hear the custom sounds!
📦 Packaging the Extension
To package the extension into a standalone .vsix file so you can install it on any machine:
Install vsce globally if you haven't already:
npm install -g @vscode/vsce
Run the packaging command:
vsce package
After packaging, you'll see a .vsix file. You can install it in standard VS Code directly from the Extensions View using the Install from VSIX... command!