mirror of
https://github.com/cmderdev/cmder.git
synced 2025-06-16 22:57:49 +08:00
Add custom loader for Powershell, improve its implementation in Cmder
Fixes #104, fixes #53, fixes #65 (my bad), related to #136, and should fix #139
This commit is contained in:
39
vendor/profile.ps1
vendored
Normal file
39
vendor/profile.ps1
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
# Global modules directory
|
||||
$global:PsGetDestinationModulePath = $PSScriptRoot + "\..\vendor\psmodules"
|
||||
|
||||
# Push to modules location
|
||||
Push-Location -Path ($PsGetDestinationModulePath)
|
||||
|
||||
# Load modules from current directory
|
||||
Get-ChildItem -Directory | `
|
||||
Foreach-Object{
|
||||
Import-Module .\$_\$_
|
||||
}
|
||||
|
||||
# Come back to PWD
|
||||
Pop-Location
|
||||
|
||||
# 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
|
||||
}
|
||||
$global:LASTEXITCODE = $realLASTEXITCODE
|
||||
return "`nλ "
|
||||
}
|
||||
|
||||
# Load special features come from posh-git
|
||||
if (Get-Module posh-git) {
|
||||
Enable-GitColors
|
||||
Start-SshAgent -Quiet
|
||||
}
|
||||
|
||||
# Move to the wanted location
|
||||
if (Test-Path Env:\CMDER_START) {
|
||||
Set-Location -Path $Env:CMDER_START
|
||||
} elseif ($Env:CMDER_ROOT -and $Env:CMDER_ROOT.StartsWith($pwd)) {
|
||||
Set-Location -Path $Env:USERPROFILE
|
||||
}
|
Reference in New Issue
Block a user