How to create an alias with multiple commands that accepts parameters in Cmder?
Asked Answered
M

1

25

I would like to know how to create one alias with multiple commands in Cmder, that accepts parameters and injects them into the commands.

Moshe answered 22/4, 2016 at 17:12 Comment(0)
M
46

To separate commands in a single alias $t would do the trick. To retrieve all the parameters passed to an alias $* would do the trick.

Examples:

  • Multiple Commands: alias serveApp=cd "C:\app" $t grunt serve
  • Parameters: alias nav=cd $*, usage: nav "C:\app"
  • Combination: alias servePath=cd $* $t grunt serve
Moshe answered 23/4, 2016 at 6:22 Comment(2)
Didn't understand the Parameter and Combination steps. Could you explain ?Alexandrite
In the parameters step: the $* will be replaced with the parameter "C:\app", thus forming cd "C:\app". The combination is two commands, first the cd to parameter, and second grunt serve.Moshe

© 2022 - 2024 — McMap. All rights reserved.