Skip to content

Commit 8f91d52

Browse files
committed
Merge branch 'release/v2.4.0'
2 parents 457c272 + 31d0ab5 commit 8f91d52

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

README.org

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,16 @@ If (-Not (Test-Path Variable:PSise)) { # Only run this in the console and not i
6868
Import-Module Get-ChildItemColor
6969

7070
Set-Alias l Get-ChildItem -option AllScope
71-
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope
71+
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope [-HideHeader]
7272
}
7373
#+end_src
7474

7575
So =l= yields colored output of =Get-ChildItem= and =ls= yields colored output
76-
of =Get-ChildItem | Format-Wide= equivalent.
77-
78-
[fn:pathProfile] ~$Home\[My ]Documents\WindowsPowerShell\Profile.ps1~
76+
of =Get-ChildItem | Format-Wide= equivalent. There is an optional
77+
~-HideHeader~ switch which will supress printing of headers (path on top) for
78+
~Get-ChildItemColorFormatWide~ when specified.
79+
80+
[fn:pathProfile] ~$Home\[My ]Documents\PowerShell\Profile.ps1~ or ~$Home\[My ]Documents\WindowsPowerShell\Profile.ps1~
7981

8082
[fn:pathProfileISE] ~$Home\[My ]Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1~
8183

@@ -116,6 +118,8 @@ $Global:GetChildItemColorVerticalSpace = 1
116118
* Authors
117119
- [[http://github.com/joonro][Joon Ro]].
118120
* Changelog
121+
** v2.4.0
122+
- Add ~HideHeader~ switch to ~Get-ChildItemColorFormatWide~ ([[https://github.com/joonro/Get-ChildItemColor/issues/29][#29]])
119123
** v2.3.0
120124
- Better handling of header printout ([[https://github.com/joonro/Get-ChildItemColor/issues/41][#41]])
121125
** v2.2.2

src/Get-ChildItemColor.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
RootModule = 'Get-ChildItemColor.psm1'
1111

1212
# Version number of this module.
13-
ModuleVersion = '2.2.3'
13+
ModuleVersion = '2.4.0'
1414

1515
# Supported PSEditions
1616
# CompatiblePSEditions = @()

src/Get-ChildItemColor.psm1

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ Function Get-ChildItemColor {
4242
Function Get-ChildItemColorFormatWide {
4343
Param(
4444
[string]$Path = "",
45-
[switch]$Force
45+
[switch]$Force,
46+
[switch]$HideHeader
4647
)
4748

4849
$nnl = $True
4950

5051
$Expression = "Get-ChildItem -Path `"$Path`" $Args"
5152

52-
if ($Force) {$Expression += " -Force"}
53+
If ($Force) {$Expression += " -Force"}
5354

5455
$Items = Invoke-Expression $Expression
5556

@@ -67,8 +68,7 @@ Function Get-ChildItemColorFormatWide {
6768
If ($Item.PSParentPath -match "FileSystem") {
6869
$ParentType = "Directory"
6970
$ParentName = $Item.PSParentPath.Replace("Microsoft.PowerShell.Core\FileSystem::", "")
70-
}
71-
ElseIf ($Item.PSParentPath -match "Registry") {
71+
} ElseIf ($Item.PSParentPath -match "Registry") {
7272
$ParentType = "Hive"
7373
$ParentName = $Item.PSParentPath.Replace("Microsoft.PowerShell.Core\Registry::", "")
7474
}
@@ -78,7 +78,12 @@ Function Get-ChildItemColorFormatWide {
7878
$LastParentName = $ParentName
7979
}
8080

81-
If ($LastParentName -ne $ParentName) {
81+
If ($i -eq 0 -and $HideHeader) {
82+
Write-Host ""
83+
}
84+
85+
# write header
86+
If ($LastParentName -ne $ParentName -and -not $HideHeader) {
8287
If ($i -ne 0 -AND $Host.UI.RawUI.CursorPosition.X -ne 0){ # conditionally add an empty line
8388
Write-Host ""
8489
}
@@ -95,7 +100,6 @@ Function Get-ChildItemColorFormatWide {
95100
For ($l=1; $l -le $GetChildItemColorVerticalSpace; $l++) {
96101
Write-Host ""
97102
}
98-
99103
}
100104

101105
$nnl = ++$i % $cols -ne 0
@@ -189,8 +193,7 @@ Function Out-Default {
189193
}
190194
}
191195

192-
End
193-
{
196+
End {
194197
Try {
195198
For ($l=1; $l -le $GetChildItemColorVerticalSpace; $l++) {
196199
Write-Host ""

0 commit comments

Comments
 (0)