Trying to replace the default PowerShell Get-ChildItem command (mapped to ls by default in PowerShell 7) with eza, however I cannot seem to find anything on how to do so
- Using
New-Aliasresults in alias is not allowed
Line |
15 | New-Alias -Name ls -Value eza.exe # Eza map to ls
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The alias is not allowed, because an alias with the name 'ls' already exists.
- Using the following function does not work and it just calls
Get-ChildItemagain (although if i, for example, switchlstolait does work so i don't think the function itself is incorrect)
function ls {
[string]$Path # path for ls
eza.exe -lab --group-directories-first --git --icons $Path
}
You need to use
-Forceto override an existing alias:Or even simpler, use
Set-Aliasor assign a value using thealias:modifier:As for defining a function with the same name, note that aliases in PowerShell are at the top of the Command Precedence, meaning, a function with the same name will not override them.
You can however, name your function differently and decorate it with the
Aliasattribute, then you're good (note, you're missing aparamblock too):