Skip to content

Commit

Permalink
Merge branch 'release/v2.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
joonro committed Jun 6, 2022
2 parents 457c272 + 31d0ab5 commit 8f91d52
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
12 changes: 8 additions & 4 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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~

Expand Down Expand Up @@ -116,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
Expand Down
2 changes: 1 addition & 1 deletion src/Get-ChildItemColor.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
RootModule = 'Get-ChildItemColor.psm1'

# Version number of this module.
ModuleVersion = '2.2.3'
ModuleVersion = '2.4.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
19 changes: 11 additions & 8 deletions src/Get-ChildItemColor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ Function Get-ChildItemColor {
Function Get-ChildItemColorFormatWide {
Param(
[string]$Path = "",
[switch]$Force
[switch]$Force,
[switch]$HideHeader
)

$nnl = $True

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

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

$Items = Invoke-Expression $Expression

Expand All @@ -67,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::", "")
}
Expand All @@ -78,7 +78,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 ""
}
Expand All @@ -95,7 +100,6 @@ Function Get-ChildItemColorFormatWide {
For ($l=1; $l -le $GetChildItemColorVerticalSpace; $l++) {
Write-Host ""
}

}

$nnl = ++$i % $cols -ne 0
Expand Down Expand Up @@ -189,8 +193,7 @@ Function Out-Default {
}
}

End
{
End {
Try {
For ($l=1; $l -le $GetChildItemColorVerticalSpace; $l++) {
Write-Host ""
Expand Down

0 comments on commit 8f91d52

Please sign in to comment.