24

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

Ramtin Soltani
  • 2,650
  • 3
  • 24
  • 45

1 Answers1

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
Ramtin Soltani
  • 2,650
  • 3
  • 24
  • 45
  • 1
    Didn't understand the Parameter and Combination steps. Could you explain ? – Benj Jul 13 '16 at 12:25
  • 1
    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. – Ramtin Soltani Jul 13 '16 at 18:18
  • Okay, I didn't undertstood this that way. Thanks ! – Benj Jul 18 '16 at 07:32