Skip to content

Default color for Files/Dirs #102

@JK-Flip-Flop96

Description

@JK-Flip-Flop96

What is the rationale behind always setting the colour value of '' (empty string) to $colorReset? I wanted a default colour for all Dirs and had to do a bit of a modification to allow it. I'd be happy to PR my changes but I want to make sure that this is even an issue to begin with.

Expected Behavior

Setting '' in a colour theme causes all entries of that type to match the colour specified. i.e. all dirs/files

Current Behavior

Overwritten to '`e[0m'

Possible Solution

Check if '' is set before overwriting.

Adding this to Convert-ColorSequence: (And an equivalent for Files)

        $cs.Types.Directories[''] = if ($ColorData.Types.Directories['']) {
             ConvertFrom-RGBColor -RGB $ColorData.Types.Directories['']
        }else{
            $colorReset
        }

And removing the overwriting from Import-ColorTheme: (Could be merged with Import-IconTheme as they'd be identical?)

function Import-ColorTheme {
    [OutputType([hashtable])]
    [cmdletbinding()]
    param()

    $hash = @{}
    (Get-ChildItem -Path $moduleRoot/Data/colorThemes).ForEach({
        $hash.Add($_.Basename, (Import-PowerShellDataFile $_.FullName))
    })
    $hash
}

I made a few other tweaks whilst I was investigating the issue so I can't be 100% sure these are the only fixes needed but I'd verify that were I to PR it.

Steps to Reproduce (for bugs)

  1. Set a colour for '' for either Files or Directories in a theme's .psd1
  2. Load theme (Add-TerminalIconsColorTheme [-Force])
  3. Set theme (Set-TerminalIconsColorTheme)
  4. ls/gci/Get-ChildItem to check colours

Context

In description above

Your Environment

Win 10 21H2. PowerShell Core v7.3.4
Terminal Icons v0.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions