Skip to content

Instantly share code, notes, and snippets.

@naraga
Created August 2, 2012 21:32
Show Gist options
  • Save naraga/3240847 to your computer and use it in GitHub Desktop.
Save naraga/3240847 to your computer and use it in GitHub Desktop.
Poor man's Git prompt
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