My use case is to create an alias for opening Firefox. Usually I used Start-Process firefox.exe
, which is fine. I would like, though, to just type xfirefox
instead. Here is what I have tried:
Quotes
Shaun> set-alias xfirefox "Start-Process firefox.exe"
Shaun> xfirefox
xfirefox : The term 'Start-Process firefox.exe' is not
recognized as the name of a cmdlet, function, script file,
or operable program...
Curlies
Shaun> set-alias xfirefox { Start-Process firefox.exe }
Set-Alias : Cannot evaluate parameter 'Value' because its
argument is specified as a script block and there is no
input. A script block cannot be evaluated without input.
This question already has answers here: All the documentation I've looked at seems to indicate that in both aliases and shell functions, the name cannot contain spaces.
An alias lets you create a shortcut name for a command, file name, or any shell text. By using aliases, you save a lot of time when doing tasks you do frequently.
Aliases are just that - aliases for command names - not command names plus arguments. What you want is a function e.g.:
function xfirefox {
Start-Process firefox.exe $args
}
Then you could launch like so:
xfirefox
xfirefox http://www.stackoverflow.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With