Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default color for Files/Dirs #102

Open
JK-Flip-Flop96 opened this issue May 5, 2023 · 2 comments
Open

Default color for Files/Dirs #102

JK-Flip-Flop96 opened this issue May 5, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@JK-Flip-Flop96
Copy link

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

@devblackops devblackops added the enhancement New feature or request label Jun 1, 2023
@devblackops
Copy link
Owner

@JK-Flip-Flop96 There is no particular rationale for not being able to set a default color for files/folders in the theme. It's just not something I needed for myself. If you want to make a PR to implement, I'll be happy to take a look at it.

@JK-Flip-Flop96
Copy link
Author

Cheers, I'll get to work on that when I get some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants