Created
September 4, 2009 12:27
-
-
Save markembling/180854 to your computer and use it in GitHub Desktop.
My preferred prompt for Powershell - includes git info.
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
# My preferred prompt for Powershell. | |
# Displays git branch and stats when inside a git repository. | |
# See http://gist.github.com/180853 for gitutils.ps1. | |
. (Resolve-Path ~/Documents/WindowsPowershell/gitutils.ps1) | |
function prompt { | |
$path = "" | |
$pathbits = ([string]$pwd).split("\", [System.StringSplitOptions]::RemoveEmptyEntries) | |
if($pathbits.length -eq 1) { | |
$path = $pathbits[0] + "\" | |
} else { | |
$path = $pathbits[$pathbits.length - 1] | |
} | |
$userLocation = $env:username + '@' + [System.Environment]::MachineName + ' ' + $path | |
$host.UI.RawUi.WindowTitle = $userLocation | |
Write-Host($userLocation) -nonewline -foregroundcolor Green | |
if (isCurrentDirectoryGitRepository) { | |
$status = gitStatus | |
$currentBranch = $status["branch"] | |
Write-Host(' [') -nonewline -foregroundcolor Yellow | |
if ($status["ahead"] -eq $FALSE) { | |
# We are not ahead of origin | |
Write-Host($currentBranch) -nonewline -foregroundcolor Cyan | |
} else { | |
# We are ahead of origin | |
Write-Host($currentBranch) -nonewline -foregroundcolor Red | |
} | |
Write-Host(' +' + $status["added"]) -nonewline -foregroundcolor Yellow | |
Write-Host(' ~' + $status["modified"]) -nonewline -foregroundcolor Yellow | |
Write-Host(' -' + $status["deleted"]) -nonewline -foregroundcolor Yellow | |
if ($status["untracked"] -ne $FALSE) { | |
Write-Host(' !') -nonewline -foregroundcolor Yellow | |
} | |
Write-Host(']') -nonewline -foregroundcolor Yellow | |
} | |
Write-Host('>') -nonewline -foregroundcolor Green | |
return " " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment