在当前的Powershell会话中创建和运行别名,
Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.
PS C:\Windows\system32> new-item alias:eadt -value "C:\adt-bundle-windows-x86_64-20140702\eclipse\eclipse.exe"
CommandType Name ModuleName
----------- ---- ----------
Alias eadt -> eclipse.exe
PS C:\Windows\system32> eadt
Run Code Online (Sandbox Code Playgroud)
但在新会话中失败:
PS C:\Windows\system32> eadt
eadt : The term 'eadt' 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.
At line:1 char:1
+ eadt
+ ~~~~
+ CategoryInfo : ObjectNotFound: (eadt:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Windows\system32>
Run Code Online (Sandbox Code Playgroud)
您应该在配置文件中保存别名(例如Linux中的.bashrc).Hava看看About_profile选择你的.
$Profile var为您提供配置文件的路径.
它存在4个不同的profil文件:
$profile.AllUsersAllHosts
C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
$profile.AllUsersCurrentHost
C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1
$profile.CurrentUserAllHosts
C:\Users\JPB\Documents\WindowsPowerShell\profile.ps1
$profile.CurrentUserCurrentHost
C:\Users\JPB\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
749 次 |
| 最近记录: |