Add coloring to the output of Get-ChildItem
Cmdlet of PowerShell. In
addition to the original functionality, this provides:
- Better performance by using
Dictionary
objects instead of regular expressions - Color support for
Format-Wide
case (ls
equivalent) - Automatically compute number of columns for
Format-Wide
case (thanks to Guillaume Collic)
git clone https://github.com/joonro/Get-ChildItem-Color.git
It is convenient to do this in your $PROFILE
[1] folder.
In your $PROFILE
, add the following:
. "Path\To\Get-ChildItem-Color\Get-ChildItem-Color.ps1"
Set-Alias l Get-ChildItem-Color -option AllScope
Set-Alias ls Get-ChildItem-Format-Wide -option AllScope
If you install it under the $PROFILE
folder, you can also do the following:
$ScriptPath = Split-Path -parent $PSCommandPath
. "$ScriptPath\Get-ChildItem-Color\Get-ChildItem-Color.ps1"
Set-Alias l Get-ChildItem-Color -option AllScope
Set-Alias ls Get-ChildItem-Format-Wide -option AllScope
This code is based on Tim Johnson's script and also Keith Hill's answer at this Stack Overflow question.
[1] | C:\Users\username\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 |