Terminal-Icons
Terminal-Icons copied to clipboard
Default color for Files/Dirs
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)
- Set a colour for '' for either Files or Directories in a theme's .psd1
- Load theme (Add-TerminalIconsColorTheme [-Force])
- Set theme (Set-TerminalIconsColorTheme)
- 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
@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.
Cheers, I'll get to work on that when I get some time.