簡體   English   中英

如何在PowerShell別名中運行多個命令

[英]How to run multiple commands in a PowerShell Alias

我正在嘗試在我的$profile文件中為PowerShell添加別名。

Set-Alias regrunt grunt;g aa;g cm 'regrunted';g ps;

當我運行regrunt ,只運行第一個命令。 如何讓這個別名運行所有命令?

PS:請不要評論“不要提交縮小文件”,我們都通過了這個。

你不能不幸。 PowerShell中的別名只能用於單個命令。

您需要定義一個函數來運行多個命令:

function regrunt {
    grunt;g aa;g cm 'regrunted';g ps;
}

PowerShell中的別名專為命令的簡單重命名而設計。 只有一個命令,沒有參數。 要做你想做的事,寫一個函數。

function regrunt {
  grunt
  g aa
  g cm 'regrunted'
  g ps
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM