2017-06-29 43 views
1

这里是我的个人资料的一部分:我的配置文件中的某些Powershell别名未加载,为什么?

#alias gs='git status' 
function GitStatus { & git status $args } 
Set-Alias -Option AllScope -Name gs -Value GitStatus 

# aliases - other ---------------------------------- 
function Touch { & echo $null >> $args } 
Set-Alias -Option AllScope -Name touch -Value Touch 
function LL { & ls } 
Set-Alias -Option AllScope -Name ll -Value LL 
function Open { & Invoke-Item $args } 
Set-Alias -Option AllScope -Name open -Value Open 

echo "Loading profile v6..." 

我的资料是:

C:\用户\ [用户名] \文档\ WindowsPowerShell \ Microsoft.PowerShell_profile.ps1

轮廓加载没有任何错误:

$ .$PROFILE 
Loading profile v6... 

但是open别名未加载。

$ open .\coverage\report.html 
open : The term 'open' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if 
a path was included, verify that the path is correct and try again. 

但是gs的别名是。

$ gs 
On branch f/listener 
Changes to be committed: 

那么我是怎么在一个情况下我的一些别名负荷有的没有?没有错误时,加载配置文件....

$ $PSVersionTable.PSVersion 
Major Minor Build Revision 
----- ----- ----- -------- 
5  1  14393 1198 
+0

'(gal open).ReferencedCommand' – PetSerAl

+0

那是什么? .. – jcollum

+0

如果这个命令没有错误地完成,那么加载'open'别名,并且这个命令显示由别名引用的命令。顺便说一句,你是否知道PowerShell不区分大小写? – PetSerAl

回答

0

尝试使用

Set-Alias open Start-Process 

我测试,它为我工作。

+0

啊,所以这是大小写敏感,是我的别名,这很奇怪,powershell使用区分大小写的参数来处理各种命令,但它不区分大小写 – jcollum

+0

别名不应区分大小写。无论我如何输入命令,别名都适用于我。 –

+0

在我的原始代码中,我依赖于区分大小写。 – jcollum

相关问题