我最近安装了Windows 10,其中包括V5 of PowerShell,或者确切地说是5.1.14393.206 ($PSVersionTable.PSVersion)。
在新计算机上,我安装了PSReadline。不过,Windows 10已经安装好了。
我的问题是,当没有可导入PSReadline的配置文件时(或者从它调用命令),如何自动加载它?
作为证据,我运行了以下代码:
$PROFILE | Get-Member -MemberType NoteProperty | % {
$path = $PROFILE.$($_.Name);
$exists = Test-Path $path;
[pscustomobject]@{ Path = $path; Exists = $exists }
}为了得到这个:
Path Exists
---- ------
C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 False
C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1 False
C:\Users\tahir\Documents\WindowsPowerShell\profile.ps1 False
C:\Users\tahir\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 False我经历了所有的https://stackoverflow.com/a/23942543/288393
Import-Module调用PSReadline,因为没有配置文件来调用它。有人能解释一下这种行为吗?
发布于 2016-11-29 16:17:43
如果进程是交互式的,控制台主机中有特殊的代码来加载PSReadline。您可以看到代码这里。
发布于 2016-11-29 10:37:34
PSReadline位于预定义的模块文件夹C:\Program Files\WindowsPowerShell\Modules中,因为它位于PowerShell的自动cmdlet发现和模块加载过程中,当调用模块中的任何函数时,模块加载过程都会加载该模块。那个过程加入PS v3。
https://stackoverflow.com/questions/40862209
复制相似问题