mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 17:59:11 +08:00
Check that git can really be used as well as posh-git
Explicitly call `import posh-git` because it doesn't have a module manifest thus powershell can't autoload it when using a cmdlet. At present the cmder repo doesn't try to download posh-git so it might be missing from the users session.
This commit is contained in:
parent
2292348f95
commit
18fc5e37c7
13
vendor/profile.ps1
vendored
13
vendor/profile.ps1
vendored
@ -5,13 +5,22 @@ if( -not $env:PSModulePath.Contains($CmderModulePath) ){
|
|||||||
$env:PSModulePath = $env:PSModulePath.Insert(0, "$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
|
# Set up a Cmder prompt, adding the git prompt parts inside git repos
|
||||||
function global:prompt {
|
function global:prompt {
|
||||||
$realLASTEXITCODE = $LASTEXITCODE
|
$realLASTEXITCODE = $LASTEXITCODE
|
||||||
$Host.UI.RawUI.ForegroundColor = "White"
|
$Host.UI.RawUI.ForegroundColor = "White"
|
||||||
Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
|
Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
|
||||||
if (Get-Module posh-git) {
|
|
||||||
Write-VcsStatus
|
Write-VcsStatus
|
||||||
|
if($gitStatus){
|
||||||
}
|
}
|
||||||
$global:LASTEXITCODE = $realLASTEXITCODE
|
$global:LASTEXITCODE = $realLASTEXITCODE
|
||||||
Write-Host "`nλ" -NoNewLine -ForegroundColor "DarkGray"
|
Write-Host "`nλ" -NoNewLine -ForegroundColor "DarkGray"
|
||||||
@ -19,7 +28,7 @@ function global:prompt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Load special features come from posh-git
|
# Load special features come from posh-git
|
||||||
if (Get-Module posh-git) {
|
if ($gitStatus) {
|
||||||
Enable-GitColors
|
Enable-GitColors
|
||||||
Start-SshAgent -Quiet
|
Start-SshAgent -Quiet
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user