52

Edit: Original solution at the bottom of this post. For a more up-to-date solution, see the accepted answer, posted by Thraka.

Colorizing Get-Childitem (dir or ls, in other words) isn't a new idea exactly, but I have not been able to locate any ideal approaches to colorizing output in Powershell. There are two general approaches for writing color-ls functions:

  • Intercepting output of Get-Childitem, and re-outputting it as text using Write-Host with the -ForegroundColor parameter. This approach allows as much granularity as possible, but reduces the output of Get-Childitem to text. As most powershell users are aware, Get-Childitem does not output text, rather, it outputs objects. Specifically, a list of FileInfo and DirectoryInfo objects. This allows a great deal of flexibility in handling Get-Childitem output.

  • Pipe the output of Get-Childitem via Invoke-Expression to Foreach-Object, changing the console foreground color before outputting each object. Kind of a mouthful, but the better option because it preserves the type of Get-Childitem's output.

Here is an example of the latter approach, provided by Tim Johnson's Powershell Blog.

function color-ls
{
    $regex_opts = ([System.Text.RegularExpressions.RegexOptions]::IgnoreCase `
          -bor [System.Text.RegularExpressions.RegexOptions]::Compiled)
    $fore = $Host.UI.RawUI.ForegroundColor
    $compressed = New-Object System.Text.RegularExpressions.Regex(
          '\.(zip|tar|gz|rar|jar|war)$', $regex_opts)
    $executable = New-Object System.Text.RegularExpressions.Regex(
          '\.(exe|bat|cmd|py|pl|ps1|psm1|vbs|rb|reg)$', $regex_opts)
    $text_files = New-Object System.Text.RegularExpressions.Regex(
          '\.(txt|cfg|conf|ini|csv|log|xml|java|c|cpp|cs)$', $regex_opts)

    Invoke-Expression ("Get-ChildItem $args") | ForEach-Object {
        if ($_.GetType().Name -eq 'DirectoryInfo') 
        {
            $Host.UI.RawUI.ForegroundColor = 'Magenta'
            echo $_
            $Host.UI.RawUI.ForegroundColor = $fore
        }
        elseif ($compressed.IsMatch($_.Name)) 
        {
            $Host.UI.RawUI.ForegroundColor = 'darkgreen'
            echo $_
            $Host.UI.RawUI.ForegroundColor = $fore
        }
        elseif ($executable.IsMatch($_.Name))
        {
            $Host.UI.RawUI.ForegroundColor = 'Red'
            echo $_
            $Host.UI.RawUI.ForegroundColor = $fore
        }
        elseif ($text_files.IsMatch($_.Name))
        {
            $Host.UI.RawUI.ForegroundColor = 'Yellow'
            echo $_
            $Host.UI.RawUI.ForegroundColor = $fore
        }
        else
        {
            echo $_
        }
    }
}

This code assigns different colors based purely on file extension, but nearly any metric could be substituted to differentiate file types. The above code produces the following output:

Colored get-childitem example

This is nearly perfect, but there is one little flaw: the first 3 lines output (Directory path, Column Headers, and horizontal separators) take on the color of the first item in the list. Tim Johnson commented in his blog:

I would rather if the header at the top wasn't always the same color as the first item, but I can't think of any way around that.

Neither can I, unfortunately. That's where Stack Overflow and its powershell gurus come in: I'm looking for a way to colorize Get-Childitem output while preserving the cmdlet's output type, without messing up the color of the header. I've done some experimentation and fiddling with this approach, but have not had any success just yet, as the first single echo call outputs the entire header and first item.

Any questions, comments, or, even better, solutions are welcome.

The Solution With Thanks to jon Z and the others who provided ideas:

Jon Z provided the perfect solution to this problem, which I have polished up a bit to match the scheme in my original question. Here it is, for anyone who is interested. Note that this requires the New-CommandWrapper cmdlet from the Powershell Cookbook. Relevant cmdlet added to bottom of this post. All of this code goes in your profile.

function Write-Color-LS
    {
        param ([string]$color = "white", $file)
        Write-host ("{0,-7} {1,25} {2,10} {3}" -f $file.mode, ([String]::Format("{0,10}  {1,8}", $file.LastWriteTime.ToString("d"), $file.LastWriteTime.ToString("t"))), $file.length, $file.name) -foregroundcolor $color 
    }

New-CommandWrapper Out-Default -Process {
    $regex_opts = ([System.Text.RegularExpressions.RegexOptions]::IgnoreCase)

     
    $compressed = New-Object System.Text.RegularExpressions.Regex(
        '\.(zip|tar|gz|rar|jar|war)$', $regex_opts)
    $executable = New-Object System.Text.RegularExpressions.Regex(
        '\.(exe|bat|cmd|py|pl|ps1|psm1|vbs|rb|reg)$', $regex_opts)
    $text_files = New-Object System.Text.RegularExpressions.Regex(
        '\.(txt|cfg|conf|ini|csv|log|xml|java|c|cpp|cs)$', $regex_opts)

    if(($_ -is [System.IO.DirectoryInfo]) -or ($_ -is [System.IO.FileInfo]))
    {
        if(-not ($notfirst)) 
        {
           Write-Host
           Write-Host "    Directory: " -noNewLine
           Write-Host " $(pwd)`n" -foregroundcolor "Magenta"           
           Write-Host "Mode                LastWriteTime     Length Name"
           Write-Host "----                -------------     ------ ----"
           $notfirst=$true
        }

        if ($_ -is [System.IO.DirectoryInfo]) 
        {
            Write-Color-LS "Magenta" $_                
        }
        elseif ($compressed.IsMatch($_.Name))
        {
            Write-Color-LS "DarkGreen" $_
        }
        elseif ($executable.IsMatch($_.Name))
        {
            Write-Color-LS "Red" $_
        }
        elseif ($text_files.IsMatch($_.Name))
        {
            Write-Color-LS "Yellow" $_
        }
        else
        {
            Write-Color-LS "White" $_
        }
        
    $_ = $null
    }
} -end {
    write-host ""
}

This produces output that looks like the following screenshot: enter image description here

If you would like the total file size line at the bottom, simply add the following code:

Remove-Item alias:ls
Set-Alias ls LS-Padded

function LS-Padded
{
    param ($dir)
    Get-Childitem $dir
    Write-Host
    getDirSize $dir
}

function getDirSize
{
    param ($dir)
    $bytes = 0

    Get-Childitem $dir | foreach-object {

        if ($_ -is [System.IO.FileInfo])
        {
            $bytes += $_.Length
        }
    }

    if ($bytes -ge 1KB -and $bytes -lt 1MB)
    {
        Write-Host ("Total Size: " + [Math]::Round(($bytes / 1KB), 2) + " KB")   
    }

    elseif ($bytes -ge 1MB -and $bytes -lt 1GB)
    {
        Write-Host ("Total Size: " + [Math]::Round(($bytes / 1MB), 2) + " MB")
    }

    elseif ($bytes -ge 1GB)
    {
        Write-Host ("Total Size: " + [Math]::Round(($bytes / 1GB), 2) + " GB")
    }    

    else
    {
        Write-Host ("Total Size: " + $bytes + " bytes")
    }
}

As has been pointed out in the comments, the PoshCode New-CommandWrapper link has died. Here is the relevant cmdlet in full:

##############################################################################
##
## New-CommandWrapper
##
## From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
##############################################################################

<#

.SYNOPSIS

Adds parameters and functionality to existing cmdlets and functions.

.EXAMPLE

New-CommandWrapper Get-Process `
      -AddParameter @{
          SortBy = {
              $newPipeline = {
                  __ORIGINAL_COMMAND__ | Sort-Object -Property $SortBy
              }
          }
      }

This example adds a 'SortBy' parameter to Get-Process. It accomplishes
this by adding a Sort-Object command to the pipeline.

.EXAMPLE

$parameterAttributes = @'
          [Parameter(Mandatory = $true)]
          [ValidateRange(50,75)]
          [Int]
'@

New-CommandWrapper Clear-Host `
      -AddParameter @{
          @{
              Name = 'MyMandatoryInt';
              Attributes = $parameterAttributes
          } = {
              Write-Host $MyMandatoryInt
              Read-Host "Press ENTER"
         }
      }

This example adds a new mandatory 'MyMandatoryInt' parameter to
Clear-Host. This parameter is also validated to fall within the range
of 50 to 75. It doesn't alter the pipeline, but does display some
information on the screen before processing the original pipeline.

#>

param(
    ## The name of the command to extend
    [Parameter(Mandatory = $true)]
    $Name,

    ## Script to invoke before the command begins
    [ScriptBlock] $Begin,

    ## Script to invoke for each input element
    [ScriptBlock] $Process,

    ## Script to invoke at the end of the command
    [ScriptBlock] $End,

    ## Parameters to add, and their functionality.
    ##
    ## The Key of the hashtable can be either a simple parameter name,
    ## or a more advanced parameter description.
    ##
    ## If you want to add additional parameter validation (such as a
    ## parameter type,) then the key can itself be a hashtable with the keys
    ## 'Name' and 'Attributes'. 'Attributes' is the text you would use when
    ## defining this parameter as part of a function.
    ##
    ## The Value of each hashtable entry is a scriptblock to invoke
    ## when this parameter is selected. To customize the pipeline,
    ## assign a new scriptblock to the $newPipeline variable. Use the
    ## special text, __ORIGINAL_COMMAND__, to represent the original
    ## command. The $targetParameters variable represents a hashtable
    ## containing the parameters that will be passed to the original
    ## command.
    [HashTable] $AddParameter
)

Set-StrictMode -Version Latest

## Store the target command we are wrapping, and its command type
$target = $Name
$commandType = "Cmdlet"

## If a function already exists with this name (perhaps it's already been
## wrapped,) rename the other function and chain to its new name.
if(Test-Path function:\$Name)
{
    $target = "$Name" + "-" + [Guid]::NewGuid().ToString().Replace("-","")
    Rename-Item function:\GLOBAL:$Name GLOBAL:$target
    $commandType = "Function"
}

## The template we use for generating a command proxy
$proxy = @'

__CMDLET_BINDING_ATTRIBUTE__
param(
__PARAMETERS__
)
begin
{
    try {
        __CUSTOM_BEGIN__

        ## Access the REAL Foreach-Object command, so that command
        ## wrappers do not interfere with this script
        $foreachObject = $executionContext.InvokeCommand.GetCmdlet(
            "Microsoft.PowerShell.Core\Foreach-Object")

        $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(
            '__COMMAND_NAME__',
            [System.Management.Automation.CommandTypes]::__COMMAND_TYPE__)

        ## TargetParameters represents the hashtable of parameters that
        ## we will pass along to the wrapped command
        $targetParameters = @{}
        $PSBoundParameters.GetEnumerator() |
            & $foreachObject {
                if($command.Parameters.ContainsKey($_.Key))
                {
                    $targetParameters.Add($_.Key, $_.Value)
                }
            }

        ## finalPipeline represents the pipeline we wil ultimately run
        $newPipeline = { & $wrappedCmd @targetParameters }
        $finalPipeline = $newPipeline.ToString()

        __CUSTOM_PARAMETER_PROCESSING__

        $steppablePipeline = [ScriptBlock]::Create(
            $finalPipeline).GetSteppablePipeline()
        $steppablePipeline.Begin($PSCmdlet)
    } catch {
        throw
    }
}

process
{
    try {
        __CUSTOM_PROCESS__
        $steppablePipeline.Process($_)
    } catch {
        throw
    }
}

end
{
    try {
        __CUSTOM_END__
        $steppablePipeline.End()
    } catch {
        throw
    }
}

dynamicparam
{
    ## Access the REAL Get-Command, Foreach-Object, and Where-Object
    ## commands, so that command wrappers do not interfere with this script
    $getCommand = $executionContext.InvokeCommand.GetCmdlet(
        "Microsoft.PowerShell.Core\Get-Command")
    $foreachObject = $executionContext.InvokeCommand.GetCmdlet(
        "Microsoft.PowerShell.Core\Foreach-Object")
    $whereObject = $executionContext.InvokeCommand.GetCmdlet(
        "Microsoft.PowerShell.Core\Where-Object")

    ## Find the parameters of the original command, and remove everything
    ## else from the bound parameter list so we hide parameters the wrapped
    ## command does not recognize.
    $command = & $getCommand __COMMAND_NAME__ -Type __COMMAND_TYPE__
    $targetParameters = @{}
    $PSBoundParameters.GetEnumerator() |
        & $foreachObject {
            if($command.Parameters.ContainsKey($_.Key))
            {
                $targetParameters.Add($_.Key, $_.Value)
            }
        }

    ## Get the argumment list as it would be passed to the target command
    $argList = @($targetParameters.GetEnumerator() |
        Foreach-Object { "-$($_.Key)"; $_.Value })

    ## Get the dynamic parameters of the wrapped command, based on the
    ## arguments to this command
    $command = $null
    try
    {
        $command = & $getCommand __COMMAND_NAME__ -Type __COMMAND_TYPE__ `
            -ArgumentList $argList
    }
    catch
    {

    }

    $dynamicParams = @($command.Parameters.GetEnumerator() |
        & $whereObject { $_.Value.IsDynamic })

    ## For each of the dynamic parameters, add them to the dynamic
    ## parameters that we return.
    if ($dynamicParams.Length -gt 0)
    {
        $paramDictionary = `
            New-Object Management.Automation.RuntimeDefinedParameterDictionary
        foreach ($param in $dynamicParams)
        {
            $param = $param.Value
            $arguments = $param.Name, $param.ParameterType, $param.Attributes
            $newParameter = `
                New-Object Management.Automation.RuntimeDefinedParameter `
                $arguments
            $paramDictionary.Add($param.Name, $newParameter)
        }
        return $paramDictionary
    }
}

<#

.ForwardHelpTargetName __COMMAND_NAME__
.ForwardHelpCategory __COMMAND_TYPE__

#>

'@

## Get the information about the original command
$originalCommand = Get-Command $target
$metaData = New-Object System.Management.Automation.CommandMetaData `
    $originalCommand
$proxyCommandType = [System.Management.Automation.ProxyCommand]

## Generate the cmdlet binding attribute, and replace information
## about the target
$proxy = $proxy.Replace("__CMDLET_BINDING_ATTRIBUTE__",
    $proxyCommandType::GetCmdletBindingAttribute($metaData))
$proxy = $proxy.Replace("__COMMAND_NAME__", $target)
$proxy = $proxy.Replace("__COMMAND_TYPE__", $commandType)

## Stores new text we'll be putting in the param() block
$newParamBlockCode = ""

## Stores new text we'll be putting in the begin block
## (mostly due to parameter processing)
$beginAdditions = ""

## If the user wants to add a parameter
$currentParameter = $originalCommand.Parameters.Count
if($AddParameter)
{
    foreach($parameter in $AddParameter.Keys)
    {
        ## Get the code associated with this parameter
        $parameterCode = $AddParameter[$parameter]

        ## If it's an advanced parameter declaration, the hashtable
        ## holds the validation and / or type restrictions
        if($parameter -is [Hashtable])
        {
            ## Add their attributes and other information to
            ## the variable holding the parameter block additions
            if($currentParameter -gt 0)
            {
                $newParamBlockCode += ","
            }

            $newParamBlockCode += "`n`n    " +
                $parameter.Attributes + "`n" +
                '    $' + $parameter.Name

            $parameter = $parameter.Name
        }
        else
        {
            ## If this is a simple parameter name, add it to the list of
            ## parameters. The proxy generation APIs will take care of
            ## adding it to the param() block.
            $newParameter =
                New-Object System.Management.Automation.ParameterMetadata `
                    $parameter
            $metaData.Parameters.Add($parameter, $newParameter)
        }

        $parameterCode = $parameterCode.ToString()

        ## Create the template code that invokes their parameter code if
        ## the parameter is selected.
        $templateCode = @"

        if(`$PSBoundParameters['$parameter'])
        {
            $parameterCode

            ## Replace the __ORIGINAL_COMMAND__ tag with the code
            ## that represents the original command
            `$alteredPipeline = `$newPipeline.ToString()
            `$finalPipeline = `$alteredPipeline.Replace(
                '__ORIGINAL_COMMAND__', `$finalPipeline)
        }
"@

        ## Add the template code to the list of changes we're making
        ## to the begin() section.
        $beginAdditions += $templateCode
        $currentParameter++
    }
}

## Generate the param() block
$parameters = $proxyCommandType::GetParamBlock($metaData)
if($newParamBlockCode) { $parameters += $newParamBlockCode }
$proxy = $proxy.Replace('__PARAMETERS__', $parameters)

## Update the begin, process, and end sections
$proxy = $proxy.Replace('__CUSTOM_BEGIN__', $Begin)
$proxy = $proxy.Replace('__CUSTOM_PARAMETER_PROCESSING__', $beginAdditions)
$proxy = $proxy.Replace('__CUSTOM_PROCESS__', $Process)
$proxy = $proxy.Replace('__CUSTOM_END__', $End)

## Save the function wrapper
Write-Verbose $proxy
Set-Content function:\GLOBAL:$NAME $proxy

## If we were wrapping a cmdlet, hide it so that it doesn't conflict with
## Get-Help and Get-Command
if($commandType -eq "Cmdlet")
{
    $originalCommand.Visibility = "Private"
}
8
  • Hello. Here are some relevant links: stackoverflow.com/a/8088587/539542
    – Animesh D
    Commented Feb 23, 2012 at 7:34
  • The header and separator are not an output from get-childitem. It is just an additional info when a filesystemobject is displayed. So you probably have to edit FileSystem.format.ps1xml...if that's even possible
    – Tom
    Commented Feb 23, 2012 at 8:25
  • Jon's solution is ideal. Once I get a well-tested and polished new version written, I'll put it in the OP for future reference. Commented Feb 23, 2012 at 20:12
  • This blog has some modifications to this approach: avinmathew.com/coloured-directory-listings-in-powershell
    – John Fouhy
    Commented Aug 5, 2013 at 5:24
  • 1
    Sadly the poshcode.org site seems to have died.
    – KERR
    Commented Jun 7, 2018 at 4:07

6 Answers 6

38

I just installed and used https://github.com/Davlind/PSColor which was painless. It supports PSGet so you can install easily with Install-Module PSColor to get it.

Note There is an updated fork of PSColor available as Color: https://www.powershellgallery.com/packages/Color/2.1.0 (Thanks @HackSlash) use Install-Module Color to get it

The objects aren't transformed so they still support piping. (It's using the New-CommandWrapper mentioned above)

It also supports other things like select-string.

PowerShell Color

13
  • 5
    This should probably be the accepted answer. Unlike the others here (didn't try joon's though) for me It Just Works without modification (I get multiple syntax errors for all other answers) and does not terribly slow down ls.
    – stijn
    Commented Dec 14, 2015 at 9:57
  • I'll try this when I've got a moment and change the accepted answer as needed. Seems like this is a more modern approach. The original answer is almost 7 years old now (but does still work - I use it every day!) Commented Jul 10, 2019 at 21:23
  • 1
    I have no idea how to get this working. I went to the project home page, read the notes theren, then I did Install-Module PSColor. Nothing happened. Closed, reopened console, nothing happened. Copied the $global setting that is on the page and put that into my $profile then closed and reopened the console. Nothing happened. Can you explain how we are meant to configure this tool please?
    – YorSubs
    Commented Dec 9, 2019 at 12:19
  • I think you need to run that as administrator the first time to install the module
    – Thraka
    Commented Dec 13, 2019 at 5:04
  • 3
    And don't forget to call Import-Module PSColor in your profile
    – Thraka
    Commented Dec 13, 2019 at 5:09
14

Modifying Out-Default is definitely the way to go. Below a - granted, sloppy - example. I'm using New-CommandWrapper from the PowerShell Cookbook.

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
        }
} 

Example Directory Listing

7
  • This looks like the answer. I'll check back once I've had a chance to play with it a bit. Commented Feb 23, 2012 at 16:24
  • Yes, this is definitely the answer. I've got some formatting issues to deal with no, but nothing I can't handle. Thanks! Commented Feb 23, 2012 at 17:13
  • Here's a thought - is there any easy way to append a newline to the end of the output? (or, for example, add a total filesize row at the bottom?) I don't know how to programatically check if an entry is the last one. EDIT: I suppose i could just write a function that calls LS then writes a newline, and alias that function. No biggie. Commented Feb 24, 2012 at 17:24
  • Just add -end {write-host ""} to the end.
    – jon Z
    Commented Feb 25, 2012 at 6:59
  • See also this blogger's extension of this solution: avinmathew.com/coloured-directory-listings-in-powershell, but beware that you will probably want to move the regexes OUTSIDE of each function evaluation to avoid very nasty slowness.
    – jhclark
    Commented Apr 7, 2014 at 15:40
4

I have another script which takes care of Format-Wide (ls) case and also has better performance by using dictionaries instead of regex: https://github.com/joonro/Get-ChildItem-Color.

3

I have another solution. You can just have a custom .format.ps1xml for it, and do some tweaks to make the coloring possible.

I have my person .format.ps1xml formating file on github.com: https://github.com/ecsousa/PSUtils/blob/master/CustomPSUtils.format.ps1xml

To use it, all you need to do is:

Update-FormatData -Prepend CustomPSUtils.format.ps1xml

Also, to make sure you go back to original Console color after a Get-ChildItem, you will need to override prompt function. Something like this:

function prompt {
    if($global:FSFormatDefaultColor) {
        [Console]::ForegroundColor = $global:FSFormatDefaultColor
    }

    "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
}
0

I could not get the main post to work (tried for about an hour trying to get the components to work without success - probably the solution there could be updated or changed to one of the more up to date solutions?). PSColor looks a good solution, but I looked around and in the end found what (in my opinion) is a much better overall solution including well-tailored color settings and seamless icon support. I've built a script to perform all of the required installation steps (just throw these lines into any Admin PowerShell console and then you just need to remember Set-ConsoleFont "LiterationMono NF" and Set-TerminalIconsColorTheme -Name DevBlackOps to activate in any console (or keep those lines in your $profile):

### Install Terminal-Icons (get LiterationMono NF Nerd font, install, add required Console registry key, then install required Modules)
$url = 'https://github.com/haasosaurus/nerd-fonts/raw/regen-mono-font-fix/patched-fonts/LiberationMono/complete/Literation%20Mono%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible.ttf'
$name = "LiterationMono NF"
$file = "$($env:TEMP)\$($name).ttf"
# Install-Module BitsTransfer   # Could be required on PS v2
Start-BitsTransfer -Source $url -Destination $file   # Download the font

$Install = $true  # $false to uninstall (or 1 / 0)
$FontsFolder = (New-Object -ComObject Shell.Application).Namespace(0x14)   # Must use Namespace part or will not install properly
$filename = (Get-ChildItem $file).Name
$filepath = (Get-ChildItem $file).FullName
$target = "C:\Windows\Fonts\$($filename)"

If (Test-Path $target -PathType Any) { Remove-Item $target -Recurse -Force } # UnInstall Font

If ((-not(Test-Path $target -PathType Container)) -and ($Install -eq $true)) { $FontsFolder.CopyHere($filepath, 16) }   # Following action performs the install, requires user to click on yes

$key = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont'   # Need to set this for console
Set-ItemProperty -Path $key -Name '000' -Value $name

Write-Host "Install-Module Terminal-Icons (Advanced Coloured dir / ls / gci listings with icons)" -ForegroundColor Yellow -BackgroundColor Black
Write-Host "   Add-TerminalIconsColorTheme, Add-TerminalIconsIconTheme, Format-TerminalIcons,"
Write-Host "   Get-TerminalIconsColorTheme, Get-TerminalIconsIconTheme, Get-TerminalIconsTheme,"
Write-Host "   Set-TerminalIconsColorTheme, Set-TerminalIconsIconTheme, Show-TerminalIconsTheme"
Write-Host "View Module Contents: " -NoNewLine ; Write-Host "get-command -module terminal-icons" -ForegroundColor Yellow

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force   # Always need this, required for all Modules
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted   # Set Microsoft PowerShell Gallery to 'Trusted'
Install-Module Terminal-Icons -Scope CurrentUser
Import-Module Terminal-Icons
Install-Module WindowsConsoleFonts
Set-ConsoleFont $name
Set-TerminalIconsColorTheme -Name DevBlackOps   # After the above are setup, can add this to line to $Profile to always load
0

It's not bad these days, powershell 7.3.8. Directory names are practically unreadable in osx (blue background), so:

$psstyle.fileinfo.directory = $psstyle.background.brightcyan

All the options and basic color choices are within $psstyle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.