A Fun Beeping Prompt

by Aug 7, 2014

All PowerShell versions

If your computer has a sound card, here is a code snippet that will drive your colleagues nuts:

function prompt
{
  1..3 | ForEach-Object {
    $frequency = Get-Random -Minimum 400 -Maximum 10000
    $duration = Get-Random -Minimum 100 -Maximum 400
    [Console]::Beep($frequency, $duration)
  }
  'PS> '
  $host.ui.RawUI.WindowTitle = Get-Location
}

This function will shorten the PowerShell prompt and instead display the current location in the title bar. That’s the productivity part. The destructive part is an irritating triple-beep with varying frequencies each time PowerShell completes a command.

Twitter This Tip! ReTweet this Tip!