From 19cb97999c565b539b812777e4cca175789ef997 Mon Sep 17 00:00:00 2001 From: Joon Ro Date: Mon, 6 Jun 2022 21:11:47 +0900 Subject: [PATCH 1/4] 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/4] 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 "" From f5c300b33f613d3a8770d0d096ab9faa93854830 Mon Sep 17 00:00:00 2001 From: Joon Ro Date: Mon, 6 Jun 2022 21:16:42 +0900 Subject: [PATCH 3/4] Add instructions about HideHeader switch --- README.org | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index 8b05fe6..95f9da7 100644 --- a/README.org +++ b/README.org @@ -68,14 +68,16 @@ If (-Not (Test-Path Variable:PSise)) { # Only run this in the console and not i Import-Module Get-ChildItemColor Set-Alias l Get-ChildItem -option AllScope - Set-Alias ls Get-ChildItemColorFormatWide -option AllScope + Set-Alias ls Get-ChildItemColorFormatWide -option AllScope [-HideHeader] } #+end_src So =l= yields colored output of =Get-ChildItem= and =ls= yields colored output -of =Get-ChildItem | Format-Wide= equivalent. - -[fn:pathProfile] ~$Home\[My ]Documents\WindowsPowerShell\Profile.ps1~ +of =Get-ChildItem | Format-Wide= equivalent. There is an optional +~-HideHeader~ switch which will supress printing of headers (path on top) for +~Get-ChildItemColorFormatWide~ when specified. + +[fn:pathProfile] ~$Home\[My ]Documents\PowerShell\Profile.ps1~ or ~$Home\[My ]Documents\WindowsPowerShell\Profile.ps1~ [fn:pathProfileISE] ~$Home\[My ]Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1~ From 31d0ab5fa8f26c5e98c7a316989b596fd0af1f39 Mon Sep 17 00:00:00 2001 From: Joon Ro Date: Mon, 6 Jun 2022 21:17:07 +0900 Subject: [PATCH 4/4] Update version number --- README.org | 2 ++ src/Get-ChildItemColor.psd1 | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 95f9da7..71e65f2 100644 --- a/README.org +++ b/README.org @@ -118,6 +118,8 @@ $Global:GetChildItemColorVerticalSpace = 1 * Authors - [[http://github.com/joonro][Joon Ro]]. * Changelog +** v2.4.0 +- Add ~HideHeader~ switch to ~Get-ChildItemColorFormatWide~ ([[https://github.com/joonro/Get-ChildItemColor/issues/29][#29]]) ** v2.3.0 - Better handling of header printout ([[https://github.com/joonro/Get-ChildItemColor/issues/41][#41]]) ** v2.2.2 diff --git a/src/Get-ChildItemColor.psd1 b/src/Get-ChildItemColor.psd1 index 804891c..9e09cba 100644 --- a/src/Get-ChildItemColor.psd1 +++ b/src/Get-ChildItemColor.psd1 @@ -10,7 +10,7 @@ RootModule = 'Get-ChildItemColor.psm1' # Version number of this module. -ModuleVersion = '2.2.3' +ModuleVersion = '2.4.0' # Supported PSEditions # CompatiblePSEditions = @()