Lunch Time Alert

by Jun 27, 2012

Here's a fun prompt function that turns your input prompt into a short prompt and displays the current path in your PowerShell window title bar. In addition, it has a lunch count down, displaying the minutes to go. Three minutes before lunch time, the prompt also emits a beep tone so you never miss the perfect time for lunch anymore.

function prompt {
    $lunchtime = Get-Date -Hour 12 -Minute 30
    $timespan = New-TimeSpan -End $lunchtime
    [Int]$minutes = $timespan.TotalMinutes
    switch ($minutes) {
        { $_ -lt 0 }   { $text = 'Lunch is over. {0}' }
        { $_ -lt 3 }   { $text = 'Prepare for lunch!  {0}' }
        default        { $text = '{1} minutes to go... {0}' }
    }

    'PS> '
    $Host.UI.RawUI.WindowTitle = $text -f (Get-Location), $minutes
    if ($minutes -lt 3) { [System.Console]::Beep() }
} 

Twitter This Tip! ReTweet this Tip!