gardebring / PowerColorLS

PowerShell script to display a colorized directory and file listing with icons
MIT License
61 stars 3 forks source link

How to configure alias for the PowerColorLS command with options? #2

Closed haosmos closed 3 years ago

haosmos commented 3 years ago

Hi!

Thank you for your wonderful script!

Please tell me how to configure alias for the PowerColorLS command with options:

-l -ds -sd -a?

In other words, I want the command "ls" to be a replacement for such a command:

ls -l -ds -sd -a

I have tried to investigate this issue and the only thing I have understood is that there is no way to pass the parameters of the cmdlet into the alias. To execute an alias with parameters, you need to use a function to do this.

But I don't understand how to write such a function for my case, because I'm completely unfamiliar with the language Powershell.

Help me, please.

gardebring commented 3 years ago

Hi @haosmos . Thanks for your kind words. You should be able to do something like this:

function PowerColorLSWithParams([string] $query = ".") { PowerColorLS $query -l -ds -sd -a }

Set-Alias -Name ls -Value PowerColorLSWithParams -Option AllScope

This will also allow you to send a path argument to the ls alias.

haosmos commented 3 years ago

Thank you so much! It works!