From 19cb97999c565b539b812777e4cca175789ef997 Mon Sep 17 00:00:00 2001 From: Joon Ro Date: Mon, 6 Jun 2022 21:11:47 +0900 Subject: [PATCH 1/2] Add HideHeader switch to Get-ChildItemColorFormatWide --- src/Get-ChildItemColor.psm1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Get-ChildItemColor.psm1 b/src/Get-ChildItemColor.psm1 index 3139d6c..041f27c 100644 --- a/src/Get-ChildItemColor.psm1 +++ b/src/Get-ChildItemColor.psm1 @@ -42,7 +42,8 @@ Function Get-ChildItemColor { Function Get-ChildItemColorFormatWide { Param( [string]$Path = "", - [switch]$Force + [switch]$Force, + [switch]$HideHeader ) $nnl = $True @@ -78,7 +79,12 @@ Function Get-ChildItemColorFormatWide { $LastParentName = $ParentName } - If ($LastParentName -ne $ParentName) { + If ($i -eq 0 -and $HideHeader) { + Write-Host "" + } + + # write header + If ($LastParentName -ne $ParentName -and -not $HideHeader) { If ($i -ne 0 -AND $Host.UI.RawUI.CursorPosition.X -ne 0){ # conditionally add an empty line Write-Host "" } From bc5c968b0085e426777b8e8c1f2093aee5f94798 Mon Sep 17 00:00:00 2001 From: Joon Ro Date: Mon, 6 Jun 2022 21:12:04 +0900 Subject: [PATCH 2/2] Improve formatting --- src/Get-ChildItemColor.psm1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Get-ChildItemColor.psm1 b/src/Get-ChildItemColor.psm1 index 041f27c..c8237d2 100644 --- a/src/Get-ChildItemColor.psm1 +++ b/src/Get-ChildItemColor.psm1 @@ -50,7 +50,7 @@ Function Get-ChildItemColorFormatWide { $Expression = "Get-ChildItem -Path `"$Path`" $Args" - if ($Force) {$Expression += " -Force"} + If ($Force) {$Expression += " -Force"} $Items = Invoke-Expression $Expression @@ -68,8 +68,7 @@ Function Get-ChildItemColorFormatWide { If ($Item.PSParentPath -match "FileSystem") { $ParentType = "Directory" $ParentName = $Item.PSParentPath.Replace("Microsoft.PowerShell.Core\FileSystem::", "") - } - ElseIf ($Item.PSParentPath -match "Registry") { + } ElseIf ($Item.PSParentPath -match "Registry") { $ParentType = "Hive" $ParentName = $Item.PSParentPath.Replace("Microsoft.PowerShell.Core\Registry::", "") } @@ -101,7 +100,6 @@ Function Get-ChildItemColorFormatWide { For ($l=1; $l -le $GetChildItemColorVerticalSpace; $l++) { Write-Host "" } - } $nnl = ++$i % $cols -ne 0 @@ -195,8 +193,7 @@ Function Out-Default { } } - End - { + End { Try { For ($l=1; $l -le $GetChildItemColorVerticalSpace; $l++) { Write-Host ""