Terminal Error Sound ๐Ÿ”Š

March 19, 2026 ยท View on GitHub

A VS Code extension that plays an audible alert whenever a terminal command exits with a non-zero exit code.

VS Code Engine License: MIT TypeScript


Table of Contents


Overview

Terminal Error Sound listens to your VS Code integrated terminal and plays a sound file the moment any command returns a non-zero exit code. Stop staring at the terminal waiting for long-running builds, tests, or deployments to finish โ€” let your ears tell you something went wrong.

A bundled default sound (Fahhh.mp3) is included out of the box so the extension works with zero configuration.


Features

  • ๐Ÿ”Š Instant audio feedback on any terminal error (exit code โ‰  0)
  • ๐ŸŽต Bring your own sound โ€” point it at any audio file on disk
  • ๐ŸŽš๏ธ Volume control (0.0 โ€“ 1.0) on macOS and Linux
  • โš™๏ธ Configurable exit-code threshold โ€” only alert on severe failures
  • ๐Ÿ”„ Toggle on/off from the status bar or Command Palette without reloading
  • ๐Ÿ›ก๏ธ Concurrent-playback guard โ€” skips overlapping triggers on rapid error bursts
  • ๐Ÿ”Œ Fallback mode โ€” optionally fires when a terminal window closes with an error (for environments without Shell Integration)
  • ๐Ÿ“‹ Structured logging in a dedicated Output Channel for easy debugging

Requirements

RequirementVersion
VS Codeโ‰ฅ 1.93
Node.js (dev only)โ‰ฅ 18
npm (dev only)โ‰ฅ 9

Shell Integration must be enabled for the primary listener to work (it is on by default in VS Code โ‰ฅ 1.93 for bash, zsh, fish, and PowerShell). See the fallback option for environments where it is unavailable.


Installation

From the Marketplace (once published)

Search for "Terminal Error Sound" in the VS Code Extensions panel, or run:

ext install sheydHD.terminal-error-sound

From a .vsix package

  1. Build the package:
    npm run package
    
  2. Install it:
    code --install-extension terminal-error-sound-1.0.0.vsix
    

Quick Start

  1. Install the extension (see above).
  2. Open a terminal inside VS Code (Ctrl+\`` / Cmd+``).
  3. Run any command that fails, e.g.:
    exit 1
    
  4. ๐Ÿ”Š You should hear the default alert sound.

No additional configuration is required for the default experience.


Configuration

All settings live under the terminalErrorSound namespace and can be edited in Settings (Ctrl+,) or directly in settings.json.

SettingTypeDefaultDescription
terminalErrorSound.enabledbooleantrueMaster switch โ€” enable or disable the extension.
terminalErrorSound.soundFilePathstring""Absolute path to a custom audio file. Leave blank to use the bundled default.
terminalErrorSound.minimumExitCodeinteger1Only trigger the sound for exit codes โ‰ฅ this value. Raise to 2 to ignore minor errors.
terminalErrorSound.volumenumber1.0Playback volume (0.0 โ€“ 1.0). Effective on macOS and Linux; ignored on Windows.
terminalErrorSound.fallbackOnTerminalClosebooleanfalseAlso trigger when a terminal closes with a non-zero exit code. Useful when Shell Integration is unavailable.

Example settings.json

{
  // Use a custom WAV file
  "terminalErrorSound.soundFilePath": "C:\\Users\\you\\sounds\\error.wav",

  // Only alert on exit codes 2 and above
  "terminalErrorSound.minimumExitCode": 2,

  // 70% volume
  "terminalErrorSound.volume": 0.7
}

Usage

Status Bar Toggle

A ๐Ÿ”Š / ๐Ÿ”‡ indicator appears in the bottom-right status bar. Click it to toggle the extension on or off globally. The change is saved to your global VS Code settings.

Command Palette

Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run:

Terminal Error Sound: Toggle Terminal Error Sound

Output Channel

All extension activity is written to a dedicated Output Channel. To view it:

  1. Open the Output panel (Ctrl+Shift+U).
  2. Select Terminal Error Sound from the dropdown.

Log entries are formatted as:

[2026-03-05T12:00:00.000Z] [INFO]  Extension activated.
[2026-03-05T12:00:05.123Z] [INFO]  Error detected โ€“ terminal: "bash", exit code: 127
[2026-03-05T12:00:05.130Z] [INFO]  Playing: /path/to/sound/Fahhh.mp3

How It Works

Terminal command exits
        โ”‚
        โ–ผ
onDidEndTerminalShellExecution
 (Shell Integration โ€“ primary)
        โ”‚
        โ”œโ”€ exitCode undefined? โ”€โ”€โ–บ skip  (Ctrl+C, empty enter, etc.)
        โ”‚
        โ”œโ”€ exitCode < minimumExitCode? โ”€โ”€โ–บ skip
        โ”‚
        โ””โ”€ Trigger SoundPlayer.play()
                โ”‚
                โ”œโ”€ Already playing? โ”€โ”€โ–บ skip (concurrent-playback guard)
                โ”‚
                โ””โ”€ Build platform command
                        โ”œโ”€ Windows  โ†’ PowerShell SoundPlayer / WPF MediaPlayer
                        โ”œโ”€ macOS    โ†’ afplay
                        โ””โ”€ Linux    โ†’ paplay โ†’ aplay โ†’ ffplay (cascade)

When Shell Integration is unavailable and fallbackOnTerminalClose is enabled, the same pipeline is triggered by onDidCloseTerminal instead.


Platform Support

Platform.wav.mp3.ogg.aiffVolume control
Windowsโœ… Nativeโœ… WPFโŒโŒโŒ
macOSโœ… afplayโœ… afplayโœ… afplayโœ… afplayโœ…
Linuxโœ… paplay/aplayโœ… ffplayโœ… paplayโŒโœ… paplay

Windows tip: .wav files use the lightweight native System.Media.SoundPlayer and are the most reliable choice. For .mp3, the WPF MediaPlayer is used, which requires no additional software.


Project Structure

terminal-error-sound/
โ”œโ”€โ”€ sound/
โ”‚   โ””โ”€โ”€ Fahhh.mp3           # Bundled default alert sound
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ extension.ts        # Activation entry point; registers listeners & commands
โ”‚   โ”œโ”€โ”€ configManager.ts    # Typed wrapper around VS Code workspace configuration
โ”‚   โ”œโ”€โ”€ soundPlayer.ts      # Cross-platform audio playback engine
โ”‚   โ””โ”€โ”€ logger.ts           # Structured OutputChannel logger
โ”œโ”€โ”€ package.json            # Extension manifest & contribution points
โ””โ”€โ”€ tsconfig.json           # TypeScript compiler options

Development

Prerequisites

  • Node.js โ‰ฅ 18
  • npm โ‰ฅ 9
  • VS Code โ‰ฅ 1.93

Setup

git clone https://github.com/sheydHD/terminal-error-sound.git
cd terminal-error-sound
npm install

Build

# One-time compile
npm run compile

# Watch mode (recompiles on save)
npm run watch

Run & Debug

  1. Open the project in VS Code.
  2. Press F5 โ€” this launches a new Extension Development Host window with the extension loaded.
  3. Open a terminal in the host window and run a failing command to test.

Lint

npm run lint

Package

npm run package
# Outputs: terminal-error-sound-<version>.vsix

Contributing

Contributions are welcome. Please follow these steps:

  1. Fork the repository and create a feature branch:
    git checkout -b feat/my-improvement
    
  2. Make your changes. Keep commits small and focused.
  3. Lint before pushing:
    npm run lint
    
  4. Open a Pull Request against main with a clear description of the change and the problem it solves.

Guidelines

  • Follow the existing TypeScript code style (enforced by ESLint).
  • Do not introduce runtime dependencies โ€” this extension intentionally has zero dependencies in package.json.
  • Test manually on the platforms affected by your change.
  • Update this README if you add new settings or change behaviour.

License

MIT ยฉ Antoni Dudij