This may be some simple solution I am missing. I would like to alias the command line:
> ls -lrt
To actually do this:
> Get-ChildItem | Sort-Object -Property LastWriteTime
The issue I see is that the ls is already aliased to Get-Children and that resolved prior to any attemps I have made such as:
New-Alias -Name 'ls -lrt' -Value 'Get-ChildItem | Sort-Object -Property LastWriteTime'
Does anyone know a way to do this without harming the previously existing alias of ls?
lsdoes without changing whatlsdoes?bash, PowerShell aliases can't inherently include parameters. Instead, you'll have to write a function which takes the parameters you want, and does what you want with them. However, PowerShell is notbash, and you should not get into the habit of duplicatingbashcommands exactly - the aliases were provided as a 'crutch' for certain common commands while you familiarize yourself with PowerShell's way of doing things.ls, are not enjoyed by all. The theory is that they will make someone new to PowerShell feel more comfortable and more accepting. This breaks down whenever someone tries anything past the most simplistic command when they find out thatlsdoes not do whatlsdoes. Those coming from Windows feel the same way aboutdir.