functionWrite-BranchName(){try{$branch = git rev-parse --abbrev-ref HEAD
if($branch-eq"HEAD"){# we're probably in detached HEAD state, so print the SHA$branch = git rev-parse --short HEAD
Write-Host" ($branch)"-ForegroundColor "red"}else{# we're on an actual branch, so print itWrite-Host" ($branch)"-ForegroundColor "blue"}}catch{# we'll end up here if we're in a newly initiated git repoWrite-Host" (no branches yet)"-ForegroundColor "yellow"}}function prompt {$base = "PS "$path = "$($executionContext.SessionState.Path.CurrentLocation)"$userPrompt = "$('>'*($nestedPromptLevel+ 1)) "Write-Host"`n$base"-NoNewline
if((Test-Path.git)-or(Test-Path.gitignore)){Write-Host$path-NoNewline -ForegroundColor "green"Write-BranchName}else{# we're not in a repo so don't bother displaying branch name/shaWrite-Host$path-ForegroundColor "green"}return$userPrompt}$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding