# Different Terminal sounds for success and failure on Mac

Save a command's exit status, play a distinct local cue for each outcome and return the original status so the notification cannot disguise a failed build.

By [Rudra Satani](https://tapnoise.com/about/#maker), who makes TapNoise · 11 October 2026

In this post

Use the command’s exit status to choose a cue, and preserve that status afterward. Otherwise a successful sound player can accidentally become the final result of a failed build.

## A small interactive wrapper

This example runs your project’s existing build and returns its result. Use it in an ordinary interactive shell; scripts with `set -e` need their own deliberate error-handling structure.

`notify_build() {  npm run build  build_status=$?  if [ "$build_status" -eq 0 ]; then  afplay /System/Library/Sounds/Glass.aiff || true  else  afplay /System/Library/Sounds/Basso.aiff || true  fi  return "$build_status" } notify_build` 

Replace the build command only with one you understand. The `|| true` applies to audio playback so a missing device or sound file does not overwrite the saved build result.

## Interpret the result narrowly

Exit status zero means the command reported success. It does not guarantee that the build script ran tests, that the tests cover the changed behaviour or that the generated application is correct.

Read output when a cue sounds. If a build runs through a pipeline, account for the shell’s pipeline-status rules rather than assuming the last command represents every earlier step.

## Keep notification logic local

For a one-off task, [success-only playback](https://tapnoise.com/blog/play-sound-when-terminal-command-finishes/) is shorter. For an agent, use [the supported connection](https://tapnoise.com/docs/connect-coding-agents/) so command completion and agent lifecycle are not confused.

Sources: macOS `afplay -h`, POSIX shell exit-status behaviour; [TapNoise cue meanings](https://tapnoise.com/docs/agent-sound-cues/).

**About the author**

Rudra Satani makes TapNoise. Spotted a mistake? Email [support@tapnoise.com](mailto:support@tapnoise.com?subject=Blog%20correction), or reach out at [@rudraxx13](https://x.com/rudraxx13).

## Related guides

- [**What the agent sounds and reactions mean**Claude Code, Codex and Cursor each play a cue when they finish, need you or hit an error. Here is what each sound means and how to hear it.](https://tapnoise.com/docs/agent-sound-cues/)

## Hear TapNoise on your Mac

Every sound is made by TapNoise itself. Try the sounds on the homepage first, then download the app.

[Download TapNoise](https://tapnoise.com/download/) · [Try the sounds](https://tapnoise.com/#try)

## More from the blog

- [**How to choose agent alert sounds you can recognise**Give completion, permission requests and failures distinct meanings, preview them at a modest level and avoid alerting on every small agent action.](https://tapnoise.com/blog/choose-agent-notification-sound/)

- [**How to hear when a Cursor agent finishes on your Mac**Connect Cursor to TapNoise for a completion cue, test a small local turn and distinguish a finished agent loop from code that has passed review.](https://tapnoise.com/blog/cursor-sound-when-agent-finishes/)

- [**How to hear when Claude Code needs permission on Mac**Use TapNoise's needs-you cue for Claude Code permission prompts, keep it distinct from completion and review the requested action before approving it.](https://tapnoise.com/blog/claude-code-permission-prompt-sound/)

- [**How to keep coding-agent alerts quiet during a meeting**Check TapNoise's microphone-based quiet mode, keep a visible way to return to the agent and test the actual headset and recording setup before a call.](https://tapnoise.com/blog/agent-alerts-during-meetings/)

Source: https://tapnoise.com/blog/terminal-sound-success-failure/
