internal/prompts/fred.prompt.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function global:prompt
{
    try
    {
        $history = Get-History -ErrorAction Ignore
        if ($history)
        {
            Write-PSFHostColor -String "[<c='sub'>$([PSUtil.Utility.PsuTimeSpanPretty]($history[-1].EndExecutionTime - $history[-1].StartExecutionTime))</c>] " -NoNewLine -DefaultColor DarkGreen
        }
    }
    catch { }
    $segments = $executionContext.SessionState.Path.CurrentLocation.Path -split "\\"
    if ($segments.Count -lt 4) { Write-Host "$($executionContext.SessionState.Path.CurrentLocation.Path)" -NoNewline }
    else { Write-Host "($($segments.Count - 2)) ..\$($segments[-2])\$($segments[-1])" -NoNewline }
    
    "> "
}