Skip to content

Commit

Permalink
Apply icon/color for files with more than one extension
Browse files Browse the repository at this point in the history
  • Loading branch information
devblackops committed Apr 9, 2021
1 parent 9672eac commit 97cb8e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Icon and color for symlinks and junctions are now shown, along with the target path.
- [**#PR23**](https://github.com/devblackops/Terminal-Icons/pull/23) Add icons/colors for common folders `.aws`, `.Azure`, `.kube`, and `.docker` (via [@cdhunt](https://github.com/cdhunt))

### Fixed

- Colors/icons for files with more than one extension now have the theme applied.

## [0.2.2] 2020-01-10

### Added
Expand Down
20 changes: 18 additions & 2 deletions Terminal-Icons/Private/Resolve-Icon.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,16 @@ function Resolve-Icon {
if (-not $iconName) {
if ($FileInfo.PSIsContainer) {
$iconName = $icons.Types.$type[$FileInfo.Name]
} else {
} elseif ($icons.Types.$type.ContainsKey($FileInfo.Extension)) {
$iconName = $icons.Types.$type[$FileInfo.Extension]
} else {
# File probably has multiple extensions
# Fallback to computing the full extension
$firstDot = $FileInfo.Name.IndexOf('.')
if ($firstDot) {
$fullExtension = $FileInfo.Name.Substring($firstDot)
$iconName = $icons.Types.$type[$fullExtension]
}
}
if (-not $iconName) {
$iconName = $icons.Types.$type['']
Expand All @@ -54,8 +62,16 @@ function Resolve-Icon {
if (-not $colorSeq) {
if ($FileInfo.PSIsContainer) {
$colorSeq = $colors.Types.$type[$FileInfo.Name]
} else {
} elseif ($colors.Types.$type.ContainsKey($FileInfo.Extension)) {
$colorSeq = $colors.Types.$type[$FileInfo.Extension]
} else {
# File probably has multiple extensions
# Fallback to computing the full extension
$firstDot = $FileInfo.Name.IndexOf('.')
if ($firstDot) {
$fullExtension = $FileInfo.Name.Substring($firstDot)
$colorSeq = $colors.Types.$type[$fullExtension]
}
}
if (-not $colorSeq) {
$colorSeq = $colors.Types.$type['']
Expand Down

0 comments on commit 97cb8e9

Please sign in to comment.