Last active
July 21, 2016 21:06
-
-
Save peschkaj/eccb7fcf8566d1e225b13f261403685e to your computer and use it in GitHub Desktop.
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
try { | |
Get-command -Name "git" -ErrorAction Stop >$null | |
Import-Module -Name "posh-git" -ErrorAction Stop >$null | |
$gitStatus = $true | |
} catch { | |
Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder." | |
$gitStatus = $false | |
} | |
function checkGit($Path) { | |
if (Test-Path -Path (Join-Path $Path '.git/') ) { | |
Write-VcsStatus | |
return | |
} | |
$SplitPath = split-path $path | |
if ($SplitPath) { | |
checkGit($SplitPath) | |
} | |
} | |
function global:prompt { | |
$realLASTEXITCODE = $LASTEXITCODE | |
$Host.UI.RawUI.ForegroundColor = "White" | |
Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green | |
if($gitStatus){ | |
checkGit($pwd.ProviderPath) | |
} | |
$global:LASTEXITCODE = $realLASTEXITCODE | |
Write-Host "`n>" -NoNewLine -ForegroundColor "DarkGray" | |
return " " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment