Created
April 16, 2009 14:58
-
-
Save aristidb/96455 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Get-GitBranchNameWithStatusIndicator { | |
| $statusOutput = Invoke-Expression 'git status 2>$null' | |
| if (!$statusOutput) { return } | |
| $branch = $statusOutput[0] | |
| if ($branch -eq "# Not currently on any branch.") { | |
| $branch = "No branch" | |
| } else { | |
| $branch = $branch.SubString("# On branch ".Length) | |
| } | |
| $statusSummary = $statusOutput[-1] | |
| if ($statusSummary -eq "nothing to commit (working directory clean)") { | |
| $statusIndicator = "" | |
| } else { | |
| $statusIndicator = "*" | |
| } | |
| return $branch + $statusIndicator | |
| } | |
| function prompt { | |
| $location = (Get-Location).ToString() | |
| $shortLocation = $location.Replace($HOME, "~") | |
| $gitStatus = Get-GitBranchNameWithStatusIndicator | |
| Write-Host ("PS " + $shortLocation) -nonewline | |
| $host.ui.rawui.WindowTitle = $location | |
| if ($gitStatus) { | |
| Write-Host (" [" + $gitStatus +"]") -nonewline -foregroundcolor Gray | |
| $host.ui.rawui.WindowTitle += (" [" + $gitStatus +"]") | |
| } | |
| Write-Host (">") -nonewline | |
| $host.ui.rawui.WindowTitle += " - PowerShell" | |
| return " " | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment