How to Make Unrar Beep After Extraction

The standard command-line unrar utility does not include a native flag or configuration file setting to play an audio chime upon completion. However, you can configure your operating system to trigger an audible bell immediately after unrar finishes unpacking. This guide details how to trigger this alert per command, set up a permanent shell function for automated beeping on Linux and macOS, and accomplish the same behavior in Windows.

Triggering a Beep via Command Chaining

Because unrar returns an exit status code of 0 upon a successful operation, you can chain the extraction command with an audio trigger using the && operator.

On Linux and macOS

Run the extraction and print the ASCII terminal bell character (\a):

unrar x archive.rar && printf '\a'

If your terminal bell is muted, you can substitute printf '\a' with an external audio player to trigger an alert sound:

  • Linux (PulseAudio/PipeWire):
    unrar x archive.rar && paplay /usr/share/sounds/freedesktop/stereo/complete.oga
  • macOS:
    unrar x archive.rar && afplay /System/Library/Sounds/Glass.aiff

On Windows

In PowerShell, invoke the console beep method upon completion:

unrar x archive.rar; [console]::beep(800, 300)

(The parameters set the frequency to 800 Hz and the duration to 300 milliseconds).

In Command Prompt (CMD), chain the command with the ASCII bell character (represented by ^G via Ctrl+G):

unrar x archive.rar && echo 

Creating a Permanent Wrapper Function

To make unrar beep automatically every time without having to type the extra commands, wrap the utility inside your shell configuration.

For Linux and macOS (.bashrc or .zshrc)

  1. Open your configuration file in a text editor:

    nano ~/.bashrc

    (Use ~/.zshrc if using macOS or Zsh).

  2. Append the following function to the bottom of the file:

    unrar() {
        command unrar "$@"
        local exit_code=$?
        if [ $exit_code -eq 0 ]; then
            printf '\a'
        fi
        return $exit_code
    }
  3. Save the file and reload the configuration:

    source ~/.bashrc

Now, typing unrar x <archive> will execute the extraction normally and ring the terminal bell whenever the command succeeds.

Terminal Emulator Requirements

If you use the ASCII bell method (printf '\a') and do not hear a sound:

  • Check Terminal Settings: Open your terminal emulator's preferences and ensure that "Audible Bell" is enabled and not set to "Visual Bell" or "Silent."
  • System Volume: Verify that alert sounds are unmuted in your system's sound settings.