Examples/UsingPoshGit.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$global:GitPromptSettings = New-GitPromptSettings
$global:GitPromptSettings.BeforeStatus = ''
$global:GitPromptSettings.AfterStatus = ''
$global:GitPromptSettings.PathStatusSeparator = ''
$global:GitPromptSettings.BeforeStash.Text = "$(Text '&ReverseSeparator;')"
$global:GitPromptSettings.AfterStash.Text = "$(Text '&Separator;')"


Set-PowerLinePrompt -SetCurrentDirectory -PowerLineFont -Title {
    -join @(
        if (Test-Elevation) { "Admin: " }
        if ($IsCoreCLR) { "pwsh - " } else { "PowerShell - " }
        Convert-Path $pwd
    )
} -Prompt @(
    { New-PromptText -Fg Gray95 -Bg Gray20 -EBg VioletRed4 $MyInvocation.HistoryId }
    { Get-Elapsed -Trim }   # only shows the minimum portion of elapsed time necessary
    { Get-Date -f "HH:mm" } # 24-hour format
    { Write-VcsStatus }
    { Get-SegmentedPath }
    { "`n" }
    { New-PromptText -Fg Gray95 -Bg Gray40 "I ${Fg:Green}♥${Fg:Gray95} PS" }
) -PSReadLinePromptText @(
    # Let PSReadLine use a red heart to let us know about syntax errors
    New-PromptText -Fg Gray95 -Bg Gray40 "I ${Fg:Green}♥${Fg:Gray95} PS${fg:Gray40}${bg:Clear}&ColorSeparator;"
    New-PromptText -Fg Gray95 -Bg Gray40 "I ${Fg:Red}♥${Fg:Gray95} PS${fg:Gray40}${bg:Clear}&ColorSeparator;"
) -Colors Gray54, Gray26