如何在 PowerShell 别名中运行多个命令 [英] How to run multiple commands in a PowerShell Alias

查看:38
本文介绍了如何在 PowerShell 别名中运行多个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 $profile 文件中向 PowerShell 添加别名.

I'm trying to add an alias to PowerShell in my $profile file.

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

当我运行 regrunt 时,只运行第一个命令.如何让这个别名运行所有命令?

When I run regrunt, only the first command is run. How can I make this alias run all of the commands?

PS:请不要评论不要提交缩小的文件",我们都已经通过了.

PS: Please no comments about "do not commit minified files", we have all passed through this.

推荐答案

不幸的是你不能.PowerShell 中的别名只能用于单个命令.

You can't unfortunately. Aliases in PowerShell can only be for a single command.

您需要定义一个函数来运行多个命令:

You will need to define a function to run multiple commands:

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

这篇关于如何在 PowerShell 别名中运行多个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆