Created
August 2, 2012 21:32
-
-
Save naraga/3240847 to your computer and use it in GitHub Desktop.
Poor man's Git prompt
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 Get-GitRepoPath | |
{ | |
@( $i=0;` | |
$pwd.path -split "\\"| ` | |
%{"$(@($pwd.path -split '\\')[0..$i] -join '\')";$i++} | ` | |
? {test-path "$_\\.git"})[0] | |
} | |
function Get-GitCurrentBranch | |
{ | |
((cat "$(Get-GitRepoPath)\.git\HEAD") -split "/")[-1] | |
} | |
function prompt | |
{ | |
"$($pwd.path)[$(Get-GitCurrentBranch)]>" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment