separate powershell functions from profile.ps1

This commit is contained in:
Dax T. Games 2019-11-03 12:59:36 -05:00
parent 661f59d0fb
commit dac4b27e28
2 changed files with 45 additions and 1 deletions

2
.gitignore vendored
View File

@ -8,7 +8,7 @@ vendor/*/*
!vendor/bin/*
!vendor/lib/*
!vendor/*
!vendor/psmodules/PsGet
!vendor/psmodules/*
config/*
!config/Readme.md

44
vendor/psmodules/Cmder.ps1 vendored Normal file
View File

@ -0,0 +1,44 @@
function Configure-Git($GIT_INSTALL_ROOT){
$env:Path += $(";" + $GIT_INSTALL_ROOT + "\cmd")
# Add "$GIT_INSTALL_ROOT\usr\bin" to the path if exists and not done already
$GIT_INSTALL_ROOT_ESC=$GIT_INSTALL_ROOT.replace('\','\\')
if ((test-path "$GIT_INSTALL_ROOT\usr\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\usr\\bin")) {
$env:path = "$env:path;$GIT_INSTALL_ROOT\usr\bin"
}
# Add "$GIT_INSTALL_ROOT\mingw[32|64]\bin" to the path if exists and not done already
if ((test-path "$GIT_INSTALL_ROOT\mingw32\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw32\\bin")) {
$env:path = "$env:path;$GIT_INSTALL_ROOT\mingw32\bin"
} elseif ((test-path "$GIT_INSTALL_ROOT\mingw64\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw64\\bin")) {
$env:path = "$env:path;$GIT_INSTALL_ROOT\mingw64\bin"
}
}
function Import-Git($Loaded){
$GitModule = Get-Module -Name Posh-Git -ListAvailable
if($GitModule | select version | where version -le ([version]"0.6.1.20160330")){
Import-Module Posh-Git > $null
}
if(-not ($GitModule) ) {
Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder."
}
# Make sure we only run once by alawys returning true
return $true
}
function checkGit($Path) {
if (Test-Path -Path (Join-Path $Path '.git') ) {
if($env:gitLoaded -eq 'false') {
$env:gitLoaded = Import-Git $gitLoaded
}
Write-VcsStatus
return
}
$SplitPath = split-path $path
if ($SplitPath) {
checkGit($SplitPath)
}
}