I wanted to set an alias for listing files in the directory, but Set-Alias -name lf -value ls -file does not seem to work. I intend to use this the Unix alias way.
An alias can't do that. From the help for Set-Alias:
You can create an alias for a cmdlet, but you cannot create an alias for a command that consists of a cmdlet and its parameters.
However, using a technique called "splatting", a function can do it easily:
function lf {
ls -file @args
}
For more information, see help about_splatting.
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