Skip to content

Instantly share code, notes, and snippets.

@taylorhutchison
Last active November 23, 2019 17:34
Show Gist options
  • Save taylorhutchison/6b2b84f5dc7915541a334b59181b1576 to your computer and use it in GitHub Desktop.
Save taylorhutchison/6b2b84f5dc7915541a334b59181b1576 to your computer and use it in GitHub Desktop.
A powershell prompt function for showing current git branch.
function Prompt {
Write-Host "PS $($executionContext.SessionState.Path.CurrentLocation)" -NoNewline
$head = git symbolic-ref HEAD
if($null -ne $head) {
Write-Host " " -NoNewline
Write-Host "[$($head.substring($head.LastIndexOf("/") +1))]" -ForegroundColor Yellow -BackgroundColor Red -NoNewline
}
"$('>' * ($nestedPromptLevel + 1)) "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment