diff --git a/src/Get-ChildItemColor.psm1 b/src/Get-ChildItemColor.psm1 index 8c3b7b0..ed77fe5 100644 --- a/src/Get-ChildItemColor.psm1 +++ b/src/Get-ChildItemColor.psm1 @@ -19,8 +19,12 @@ function Get-FileColor($item) { if ([bool]($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -and (-not $inOneDrive)) { $key = 'Symlink' - } elseif ($item.GetType().Name -eq 'DirectoryInfo') { - $key = 'Directory' + } elseif ($item.IsReadOnly) { + $key = 'ReadOnly' + } elseif ($item.Attributes -band [System.IO.FileAttributes]::Hidden) { + $key = 'Hidden' + } elseif ($item.Attributes -band [System.IO.FileAttributes]::System) { + $key = 'System' } elseif ($item.PSobject.Properties.Name -contains "Extension") { If ($GetChildItemColorTable.File.ContainsKey($item.Extension)) { $key = $item.Extension @@ -28,6 +32,22 @@ function Get-FileColor($item) { } $Color = $GetChildItemColorTable.File[$key] + + + $keyRegex = "" + + if ($key -ne 'Symlink') { + foreach ($regex in $GetChildItemColorRegExTable.File.Keys) { + if ($item.Name -match $regex) { + $keyRegex = $regex + } + } + } + if ($keyRegex -ne "") { + $Color = $GetChildItemColorRegExTable.File[$keyRegex] + } + + return $Color } diff --git a/src/Get-ChildItemColorTable.ps1 b/src/Get-ChildItemColorTable.ps1 index 88dd8f8..9b53956 100644 --- a/src/Get-ChildItemColorTable.ps1 +++ b/src/Get-ChildItemColorTable.ps1 @@ -1,4 +1,12 @@ $global:GetChildItemColorExtensions = @{} +$global:GetChildItemColorProps = @{} + +$global:GetChildItemColorRegExTable = @{ + File = @{ Default = $OriginalForegroundColor } +} + +# starts with dot +$GetChildItemColorRegExTable.File.Add('^[.]','DarkRed') $GetChildItemColorExtensions.Add( 'CompressedList', @@ -168,6 +176,10 @@ $global:GetChildItemColorTable = @{ Match = @{ Default = $OriginalForegroundColor } } +#$GetChildItemColorTable.File.Add('Archive',"DarkRed") +$GetChildItemColorTable.File.Add('Hidden',"DarkRed") +$GetChildItemColorTable.File.Add('System',"DarkRed") +$GetChildItemColorTable.File.Add('ReadOnly',"DarkRed") $GetChildItemColorTable.File.Add('Directory', "Blue") $GetChildItemColorTable.File.Add('Symlink', "Cyan")