15

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

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

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

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

2 Answers 2

29

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;
}
Sign up to request clarification or add additional context in comments.

Comments

8

Aliases in PowerShell are designed for a simple renaming of commands. Only one command, no parameters. To do what you want, write a function.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.