I mean to colorize the output of ls
.
I checked Powershell: Properly coloring Get-Childitem output once and for all.
The two options appear to be:
As mentioned in the comments, New-CommandWrapper
is packaged as a script, rather than as a function, so you'll need to edit the script file slightly if you want to dot-source it:
function New-CommandWrapper {
at the very top of New-CommandWrapper.ps1
}
on the very last lineNow you can dot-source it (from your profile if need be) and use the example given in the linked answer:
PS C:\> . .\path\to\New-CommandWrapper.ps1
PS C:\> New-CommandWrapper Out-Default `
>>> -Process {
>>> if(($_ -is [System.IO.DirectoryInfo]) -or ($_ -is [System.IO.FileInfo]))
>>> {if(-not ($notfirst)) {
>>> Write-Host " Directory: $(pwd)`n"
>>> Write-Host "Mode LastWriteTime Length Name"
>>> Write-Host "---- ------------- ------ ----"
>>> $notfirst=$true
>>> }
>>> if ($_ -is [System.IO.DirectoryInfo]) {
>>> Write-host ("{0,-7} {1,25} {2,10} {3}" -f $_.mode, ([String]::Format("{0,10} {1,8}", $_.LastWriteTime.ToString("d"), $_.LastWriteTime.ToString("t"))), $_.length, $_.name) -foregroundcolor "yellow" }
>>> else {
>>> Write-host ("{0,-7} {1,25} {2,10} {3}" -f $_.mode, ([String]::Format("{0,10} {1,8}", $_.LastWriteTime.ToString("d"), $_.LastWriteTime.ToString("t"))), $_.length, $_.name) -foregroundcolor "green" }
>>> $_ = $null
>>> }
>>>}