Skip to content

Instantly share code, notes, and snippets.

@luthermonson
Created January 21, 2021 14:57
Show Gist options
  • Save luthermonson/3cd749e67792dae3b299d192fe71672a to your computer and use it in GitHub Desktop.
Save luthermonson/3cd749e67792dae3b299d192fe71672a to your computer and use it in GitHub Desktop.
Powershell Prompt() with Git Branch
function prompt() {
$host.ui.RawUI.WindowTitle = $pwd
$p = $pwd
if ($p -Match [regex]::Escape($HOME)) {
$p = $p -Replace [regex]::Escape($HOME), "~"
}
Write-Host -NoNewline $p
if (Test-Path -Path $pwd/.git) {
$branch = $(git rev-parse --abbrev-ref HEAD)
Write-Host -NoNewline " [$branch]"
}
return " > "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment