问题描述
我试图设置一个Windows PowerShell别名来运行具有特定参数的MinGW的g ++可执行文件。但是,这些参数需要在文件名和其他参数之后。我不想经历试图建立一个功能和所有这一切的麻烦。有没有一种方法可以简单地说出如下内容:
alias mybuild =g ++ {args} -lib1 -lib2 ...
或者这些行中的内容?我并不熟悉PowerShell,并且我很难找到解决方案。任何人?
您希望使用一个函数,而不是别名,正如Roman提到的。就像这样: 试试这个,下面是一个简单的例子: 您可能还想将其放入配置文件中,以便在运行PowerShell时使其可用。您的个人资料文件的名称包含在 I'm trying to set up a Windows PowerShell alias to run MinGW's g++ executable with certain parameters. However, these parameters need to come after the file name and other arguments. I don't want to go through the hassle of trying to set up a function and all of that. Is there a way to simply say something like: or something along those lines? I am not all that familiar with PowerShell, and I'm having a difficult time finding a solution. Anyone? You want to use a function, not an alias, as Roman mentioned. Something like this: To try this out, here's a simple example: You might also want to put this in your profile in order to have it available whenever you run PowerShell. The name of your profile file is contained in 这篇关于我怎样才能在中间写一个带有参数的PowerShell别名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
pre $ function mybuild {g ++ $ args -lib1 -lib2 ...}
$ c
$ b
PS>函数docmd {cmd / c $ args there}
PS> docmd echo hello
hello there
PS>
$ profile
中。alias mybuild="g++ {args} -lib1 -lib2 ..."
function mybuild { g++ $args -lib1 -lib2 ... }
PS> function docmd { cmd /c $args there }
PS> docmd echo hello
hello there
PS>
$profile
.