-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This should be faster too as we won't automatically import all functions to the session. Powershell now knows where to look before declaring they don't exist.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
# Global modules directory | ||
$global:PsGetDestinationModulePath = $PSScriptRoot + "\..\vendor\psmodules" | ||
# Add Cmder modules directory to the autoload path. | ||
$CmderModulePath = Join-path $PSScriptRoot "psmodules/" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Jackbennett
Author
Contributor
|
||
|
||
# Push to modules location | ||
Push-Location -Path ($PsGetDestinationModulePath) | ||
|
||
# Load modules from current directory | ||
Import-Module .\PsGet\PsGet | ||
Get-ChildItem -Exclude "PsGet" -Directory -Name | Foreach-Object { | ||
Import-Module .\$_\$_ | ||
if( -not $env:PSModulePath.Contains($CmderModulePath) ){ | ||
$env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;") | ||
} | ||
|
||
# Come back to PWD | ||
Pop-Location | ||
|
||
# Set up a Cmder prompt, adding the git prompt parts inside git repos | ||
function global:prompt { | ||
$realLASTEXITCODE = $LASTEXITCODE | ||
|
6 comments
on commit e811c60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very satisfied with this change: it's not fully compatible with the portable behavior of Cmder.
- It changes variable
$env:PSModulePath
globally on the computer - Without
global:PsGetDestinationModulePath
, PsGet don't install new module in the Cmder directory
I'm sure modules loading is improvable, but... 😃
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LeoColomb What do you suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$env
is a process level variable whereas Env:
would be your user or system level scope I forget how to tell.
do $env:psModilePath
in cmder then run a new powershell -noprofile
and again $env:psModulePath
you will see it's not there.
I would have to test how PsGetDestinationModulePath
is working I haven't used oneGet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Environment]::GetEnvironmentVariable("psmodulepath", "process")
[Environment]::GetEnvironmentVariable("psmodulepath", "user")
[Environment]::GetEnvironmentVariable("psmodulepath", "machine")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've spend 5 minutes searching, not to but rude just to clarify I may be ill informed.
I found psget/psget#105 and I suspect psget should fix this upstream. Using the most specific psModulePath location makes the most sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks for clarification!
This line is raising error in Powershell v2.0:
The cause of this is that $PSScriptRoot gets filled only when running in a psm1 module in PowerShell v2.0.
It has been fixed since PowerShell v3.0, but not in v2.0, which is default version in Windows 7:
https://connect.microsoft.com/PowerShell/feedback/details/522951/psscriptroot-only-works-with-modules
For PowerShell 2.0 compatibility, could you add the following line to initialize $PSScriptRoot in PowerShell v2.0? :