Skip to content

Commit

Permalink
Merge pull request #440 from Jackbennett/proper-git-check
Browse files Browse the repository at this point in the history
git and Posh-git check
  • Loading branch information
MartiUK committed Mar 25, 2015
2 parents 2292348 + c466698 commit 520e7cf
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions vendor/profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,41 @@ if( -not $env:PSModulePath.Contains($CmderModulePath) ){
$env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;")
}

try {
Get-command -Name "git" -ErrorAction Stop >$null
Import-Module -Name "posh-git" -ErrorAction Stop >$null
$gitStatus = $true
} catch {
Write-Warning "Missing git support"
$gitStatus = $false
}

function checkGit($Path) {
if (Test-Path -Path (Join-Path $Path '.git/') ) {
Write-VcsStatus
return
}
$SplitPath = split-path $path
if ($SplitPath) {
checkGit($SplitPath)
}
}

# Set up a Cmder prompt, adding the git prompt parts inside git repos
function global:prompt {
$realLASTEXITCODE = $LASTEXITCODE
$Host.UI.RawUI.ForegroundColor = "White"
Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
if (Get-Module posh-git) {
Write-VcsStatus
if($gitStatus){
checkGit($pwd.ProviderPath)
}
$global:LASTEXITCODE = $realLASTEXITCODE
Write-Host "`nλ" -NoNewLine -ForegroundColor "DarkGray"
return " "
}

# Load special features come from posh-git
if (Get-Module posh-git) {
if ($gitStatus) {
Enable-GitColors
Start-SshAgent -Quiet
}
Expand Down

0 comments on commit 520e7cf

Please sign in to comment.