# encoding: ascii
# api: powershell
# title: coolprompt
# description: A cool prompt function. Insert code into your profile script (“C:\Users\%username%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1”). Must use Consolas font in powershell (set font, then restart powershell) for special characters to appear correctly. Displays path + uptime in title, example prompt as: jgentile@quadbox●~\powershell►
# version: 0.1
# type: class
# license: CC0
# x-poshcode-id: 1788
# x-archived: 2010-04-25T07:49:55
#
#
$global:wmilocalcomputer = get-WMIObject -class Win32_OperatingSystem -computer "."
$global:lastboottime=[System.Management.ManagementDateTimeconverter]::ToDateTime($wmilocalcomputer.lastbootuptime)
$global:originaltitle = [console]::title
function prompt
{
$up=$(get-date)-$lastboottime
$upstr="$([datetime]::now.toshorttimestring()) $([datetime]::now.toshortdatestring()) up $($up.days) days, $($up.hours) hours, $($up.minutes) minutes"
$dir = $pwd.path
$homedir = (get-psprovider 'FileSystem').home
if ($homedir -ne "" -and $dir.toupper().startswith($homedir.toupper()))
{
$dir=$dir.remove(0,$homedir.length).insert(0,'~')
}
$retstr = "$env:username@$($env:computername.tolower())●$dir"
[console]::title = "$global:originaltitle ♦ $retstr ♦ $upstr"
return "$retstr►"
}