2017-06-29 36 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

相關問題