diff --git a/vendor/profile.ps1 b/vendor/profile.ps1 index 4d3152c..5415783 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -5,13 +5,22 @@ 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 +} + # 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){ } $global:LASTEXITCODE = $realLASTEXITCODE Write-Host "`nλ" -NoNewLine -ForegroundColor "DarkGray" @@ -19,7 +28,7 @@ function global:prompt { } # Load special features come from posh-git -if (Get-Module posh-git) { +if ($gitStatus) { Enable-GitColors Start-SshAgent -Quiet }