Created
January 21, 2021 14:57
-
-
Save luthermonson/3cd749e67792dae3b299d192fe71672a to your computer and use it in GitHub Desktop.
Powershell Prompt() with Git Branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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