Nic*_*tti 2 windows powershell
我正在尝试在$profile文件中为PowerShell添加别名。
Set-Alias regrunt grunt;g aa;g cm 'regrunted';g ps;
Run Code Online (Sandbox Code Playgroud)
当我运行时regrunt,仅运行第一个命令。如何使该别名运行所有命令?
PS:请不要发表有关“不提交缩小文件”的评论,我们都通过了此评论。
PowerShell 中的别名旨在对命令进行简单的重命名。只有一个命令,没有参数。为了做你想做的事,写一个函数。
function regrunt {
grunt
g aa
g cm 'regrunted'
g ps
}
Run Code Online (Sandbox Code Playgroud)
您不能不幸。PowerShell中的别名只能用于单个命令。
您将需要定义一个函数来运行多个命令:
function regrunt {
grunt;g aa;g cm 'regrunted';g ps;
}
Run Code Online (Sandbox Code Playgroud)