Skip to content

Commit db595a6

Browse files
Merge pull request #274 from StartAutomating/Posh-Format
Posh 0.1.8: Posh Formatting
2 parents 4358f65 + 344d9d7 commit db595a6

12 files changed

+263
-19
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## Posh 0.1.8: Posh Formatting
2+
3+
* New Formatting:
4+
* Get-Service shows up in color! (#265)
5+
* Get-Event gets a table formatter (and .EventID, .SourceID, .Time) (#268)
6+
* Get-FileHash groups by algorithm and autosizes (#270)
7+
* Improving Formatting:
8+
* Get-Command now shows Source, not Module (#266) ( thanks @ehmiiz ! )
9+
* Improving Enclosure Support in Links (#272)
10+
11+
---
12+
113
## Posh 0.1.7: Posh Presentation
214

315
* New and Improved Formatting:

Formatting/Command.format.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Write-FormatView -TypeName System.Management.Automation.CommandInfo, System.Mana
55
System.Management.Automation.CmdletInfo,
66
System.Management.Automation.ExternalScriptInfo,
77
System.Management.Automation.FilterInfo,
8-
System.Management.Automation.FunctionInfo -GroupByProperty CommandType -Property Name, Module -StyleProperty @{
8+
System.Management.Automation.FunctionInfo -GroupByProperty CommandType -Property Name, Source -StyleProperty @{
99
Name = {
1010
switch -regex ($_.Name)
1111
{

Formatting/FileHash.format.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Write-FormatView -TypeName Microsoft.PowerShell.Commands.FileHashInfo -GroupByProperty Algorithm -Property Hash, Path -AutoSize

Formatting/PSEventArgs.format.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Write-FormatView -TypeName System.Management.Automation.PSEventArgs -Property EventId, SourceId, Time, Sender, SourceArgs, MessageData -AlignProperty ([Ordered]@{
2+
EventID = 'Right'
3+
SourceID = 'Left'
4+
Time = 'Center'
5+
Sender = 'Left'
6+
}) -VirtualProperty @{
7+
EventID = { "" + $_.EventID + ' '}
8+
Time = { $_.Time.ToShortTimeString() }
9+
}

Formatting/Posh/Posh.LinkControl.format.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ Write-FormatView -TypeName n/a -Name "Posh.Link.Play" -AsControl -Action {
2121
@(
2222
if ($_.enclosure.url -and
2323
$psStyle.FormatHyperlink -and -not $env:GITHUB_WORKSPACE) {
24-
" $($psStyle.FormatHyperlink("", $_.enclosure.url)) "
24+
" $($psStyle.FormatHyperlink("(▶ $(@($_.enclosure.type -split '/')[0]))", $_.enclosure.url)) "
2525
}
2626
) -join ''
2727
}
2828

2929
Write-FormatView -TypeName n/a -Name "Posh.Link.Line" -AsControl -Action {
3030
Write-FormatViewExpression -ControlName Posh.Link -ScriptBlock { $_ }
31-
Write-FormatViewExpression -Newline
31+
Write-FormatViewExpression -ControlName Posh.Link.Play -ScriptBlock { $_ }
32+
Write-FormatViewExpression -Newline
3233
}

Formatting/Service.format.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Write-FormatView -Type System.ServiceProcess.ServiceController -Property Status, Name, DisplayName -StyleProperty @{
2+
Status = {
3+
switch ($_.Status) {
4+
Stopped {
5+
'Formatting.Warning'
6+
}
7+
Running {
8+
'Foreground.Green','Bold'
9+
}
10+
default {
11+
'Formatting.Error'
12+
}
13+
}
14+
}
15+
} -AutoSize

Posh.format.ps1xml

Lines changed: 178 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ $script:TreeDepth++;</ScriptBlock>
134134
@(
135135
if ($_.enclosure.url -and
136136
$psStyle.FormatHyperlink -and -not $env:GITHUB_WORKSPACE) {
137-
" $($psStyle.FormatHyperlink("", $_.enclosure.url)) "
137+
" $($psStyle.FormatHyperlink("(▶ $(@($_.enclosure.type -split '/')[0]))", $_.enclosure.url)) "
138138
}
139139
) -join ''
140140
</ScriptBlock>
@@ -154,6 +154,10 @@ $script:TreeDepth++;</ScriptBlock>
154154
<ScriptBlock> $_ </ScriptBlock>
155155
<CustomControlName>Posh.Link</CustomControlName>
156156
</ExpressionBinding>
157+
<ExpressionBinding>
158+
<ScriptBlock> $_ </ScriptBlock>
159+
<CustomControlName>Posh.Link.Play</CustomControlName>
160+
</ExpressionBinding>
157161
<NewLine />
158162
</CustomItem>
159163
</CustomEntry>
@@ -5394,7 +5398,37 @@ $_ |
53945398
</ScriptBlock>
53955399
</TableColumnItem>
53965400
<TableColumnItem>
5397-
<PropertyName>Module</PropertyName>
5401+
<PropertyName>Source</PropertyName>
5402+
</TableColumnItem>
5403+
</TableColumnItems>
5404+
</TableRowEntry>
5405+
</TableRowEntries>
5406+
</TableControl>
5407+
</View>
5408+
<View>
5409+
<Name>Microsoft.PowerShell.Commands.FileHashInfo</Name>
5410+
<ViewSelectedBy>
5411+
<TypeName>Microsoft.PowerShell.Commands.FileHashInfo</TypeName>
5412+
</ViewSelectedBy>
5413+
<GroupBy>
5414+
<PropertyName>Algorithm</PropertyName>
5415+
</GroupBy>
5416+
<TableControl>
5417+
<AutoSize />
5418+
<TableHeaders>
5419+
<TableColumnHeader>
5420+
</TableColumnHeader>
5421+
<TableColumnHeader>
5422+
</TableColumnHeader>
5423+
</TableHeaders>
5424+
<TableRowEntries>
5425+
<TableRowEntry>
5426+
<TableColumnItems>
5427+
<TableColumnItem>
5428+
<PropertyName>Hash</PropertyName>
5429+
</TableColumnItem>
5430+
<TableColumnItem>
5431+
<PropertyName>Path</PropertyName>
53985432
</TableColumnItem>
53995433
</TableColumnItems>
54005434
</TableRowEntry>
@@ -5798,6 +5832,60 @@ $_ |
57985832
</TableRowEntries>
57995833
</TableControl>
58005834
</View>
5835+
<View>
5836+
<Name>System.Management.Automation.PSEventArgs</Name>
5837+
<ViewSelectedBy>
5838+
<TypeName>System.Management.Automation.PSEventArgs</TypeName>
5839+
</ViewSelectedBy>
5840+
<TableControl>
5841+
<TableHeaders>
5842+
<TableColumnHeader>
5843+
<Label>EventId</Label>
5844+
<Alignment>Right</Alignment>
5845+
</TableColumnHeader>
5846+
<TableColumnHeader>
5847+
<Alignment>Left</Alignment>
5848+
</TableColumnHeader>
5849+
<TableColumnHeader>
5850+
<Label>Time</Label>
5851+
<Alignment>Center</Alignment>
5852+
</TableColumnHeader>
5853+
<TableColumnHeader>
5854+
<Alignment>Left</Alignment>
5855+
</TableColumnHeader>
5856+
<TableColumnHeader>
5857+
<Alignment>Left</Alignment>
5858+
</TableColumnHeader>
5859+
<TableColumnHeader>
5860+
<Alignment>Left</Alignment>
5861+
</TableColumnHeader>
5862+
</TableHeaders>
5863+
<TableRowEntries>
5864+
<TableRowEntry>
5865+
<TableColumnItems>
5866+
<TableColumnItem>
5867+
<ScriptBlock> "" + $_.EventID + ' '</ScriptBlock>
5868+
</TableColumnItem>
5869+
<TableColumnItem>
5870+
<PropertyName>SourceId</PropertyName>
5871+
</TableColumnItem>
5872+
<TableColumnItem>
5873+
<ScriptBlock> $_.Time.ToShortTimeString() </ScriptBlock>
5874+
</TableColumnItem>
5875+
<TableColumnItem>
5876+
<PropertyName>Sender</PropertyName>
5877+
</TableColumnItem>
5878+
<TableColumnItem>
5879+
<PropertyName>SourceArgs</PropertyName>
5880+
</TableColumnItem>
5881+
<TableColumnItem>
5882+
<PropertyName>MessageData</PropertyName>
5883+
</TableColumnItem>
5884+
</TableColumnItems>
5885+
</TableRowEntry>
5886+
</TableRowEntries>
5887+
</TableControl>
5888+
</View>
58015889
<View>
58025890
<Name>System.Management.Automation.PSMemberInfo</Name>
58035891
<ViewSelectedBy>
@@ -6445,6 +6533,94 @@ $module = $_
64456533
</CustomEntries>
64466534
</CustomControl>
64476535
</View>
6536+
<View>
6537+
<Name>System.ServiceProcess.ServiceController</Name>
6538+
<ViewSelectedBy>
6539+
<TypeName>System.ServiceProcess.ServiceController</TypeName>
6540+
</ViewSelectedBy>
6541+
<TableControl>
6542+
<AutoSize />
6543+
<TableHeaders>
6544+
<TableColumnHeader>
6545+
<Label>Status</Label>
6546+
</TableColumnHeader>
6547+
<TableColumnHeader>
6548+
</TableColumnHeader>
6549+
<TableColumnHeader>
6550+
</TableColumnHeader>
6551+
</TableHeaders>
6552+
<TableRowEntries>
6553+
<TableRowEntry>
6554+
<TableColumnItems>
6555+
<!-- {ConditionalStyle:"
6556+
switch ($_.Status) {
6557+
Stopped {
6558+
&apos;Formatting.Warning&apos;
6559+
}
6560+
Running {
6561+
&apos;Foreground.Green&apos;,&apos;Bold&apos;
6562+
}
6563+
default {
6564+
&apos;Formatting.Error&apos;
6565+
}
6566+
}
6567+
"}-->
6568+
<TableColumnItem>
6569+
<ScriptBlock>
6570+
$CellColorValue = $($Script:_LastCellStyle = $($__ = $_;. {
6571+
switch ($_.Status) {
6572+
Stopped {
6573+
'Formatting.Warning'
6574+
}
6575+
Running {
6576+
'Foreground.Green','Bold'
6577+
}
6578+
default {
6579+
'Formatting.Error'
6580+
}
6581+
}
6582+
};$_ = $__);$Script:_LastCellStyle)
6583+
6584+
$CellColorValue = if ($psStyle) {
6585+
@(foreach ($styleProp in $CellColorValue) {
6586+
if ($styleProp -match '^\$') {
6587+
$ExecutionContext.SessionState.InvokeCommand.InvokeScript($styleProp)
6588+
}
6589+
elseif ($styleProp -match '\.') {
6590+
$targetObject = $psStyle
6591+
foreach ($dotProperty in $styleProp -split '(?&lt;!\.)\.') {
6592+
if ($targetObject.Item -is [Management.Automation.PSMethodInfo] -or
6593+
$targetObject -is [Collections.IDictionary]) {
6594+
$targetObject = $targetObject[$dotProperty]
6595+
} else {
6596+
$targetObject = $targetObject.$dotProperty
6597+
}
6598+
}
6599+
if ($targetObject) {
6600+
$targetObject
6601+
}
6602+
}
6603+
else {
6604+
$psStyle.$styleProp
6605+
}
6606+
}) -join ''
6607+
}
6608+
6609+
$output = . {$_.'Status'}
6610+
@($CellColorValue; $output; $psStyle.Reset) -join ''
6611+
</ScriptBlock>
6612+
</TableColumnItem>
6613+
<TableColumnItem>
6614+
<PropertyName>Name</PropertyName>
6615+
</TableColumnItem>
6616+
<TableColumnItem>
6617+
<PropertyName>DisplayName</PropertyName>
6618+
</TableColumnItem>
6619+
</TableColumnItems>
6620+
</TableRowEntry>
6621+
</TableRowEntries>
6622+
</TableControl>
6623+
</View>
64486624
<View>
64496625
<Name>Process.Heatmap</Name>
64506626
<ViewSelectedBy>

Posh.psd1

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ModuleVersion = '0.1.7'
2+
ModuleVersion = '0.1.8'
33
FormatsToProcess = 'Posh.format.ps1xml'
44
TypesToProcess = 'Posh.types.ps1xml'
55
RootModule = 'Posh.psm1'
@@ -15,20 +15,15 @@
1515
IconURI = 'https://raw.githubusercontent.com/StartAutomating/Posh/main/Assets/Posh.png'
1616
Tags = 'Posh', '.ps1xml', 'Format','Output','Types', 'Colorized', 'Prompt', 'Customization'
1717
ReleaseNotes = @'
18-
## Posh 0.1.7: Posh Presentation
18+
## Posh 0.1.8: Posh Formatting
1919
20-
* New and Improved Formatting:
21-
* Get-Member formatting - Highlighting PowerShell Members (#226)
22-
* Adding Formatting for PSMemberInfo (#246)
23-
* Adding Formatting for MeasureInfo (#247)
24-
* New Blogs
25-
* PowerShell Weekly (#255)
26-
* Host Improvements
27-
* Adding Posh.Host.Cursor (#134, #135, #243, #244, #245, #248, #249, #250, #251, #252, #253, #259, #261)
28-
* Prompt Improvements
29-
* Improving stackable functions (#138) (thanks @mdgrs !)
30-
* Posh.Prompt Tests (#256)
31-
* Adding PSModuleInfo.get_README (#263)
20+
* New Formatting:
21+
* Get-Service shows up in color! (#265)
22+
* Get-Event gets a table formatter (and .EventID, .SourceID, .Time) (#268)
23+
* Get-FileHash groups by algorithm and autosizes (#270)
24+
* Improving Formatting:
25+
* Get-Command now shows Source, not Module (#266) ( thanks @ehmiiz ! )
26+
* Improving Enclosure Support in Links (#272)
3227
3328
---
3429

Posh.types.ps1xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,6 +3162,23 @@ $posh.ExecutionContext.SessionState.PSVariable.Set("function:$($this.FunctionNam
31623162
</ScriptProperty>
31633163
</Members>
31643164
</Type>
3165+
<Type>
3166+
<Name>System.Management.Automation.PSEventArgs</Name>
3167+
<Members>
3168+
<AliasProperty>
3169+
<Name>EventID</Name>
3170+
<ReferencedMemberName>EventIdentifier</ReferencedMemberName>
3171+
</AliasProperty>
3172+
<AliasProperty>
3173+
<Name>SourceID</Name>
3174+
<ReferencedMemberName>SourceIdentifier</ReferencedMemberName>
3175+
</AliasProperty>
3176+
<AliasProperty>
3177+
<Name>Time</Name>
3178+
<ReferencedMemberName>TimeGenerated</ReferencedMemberName>
3179+
</AliasProperty>
3180+
</Members>
3181+
</Type>
31653182
<Type>
31663183
<Name>System.Management.Automation.PSModuleInfo</Name>
31673184
<Members>

Types/PSEventArgs/Alias.psd1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@{
2+
EventID = 'EventIdentifier'
3+
SourceID = 'SourceIdentifier'
4+
Time = 'TimeGenerated'
5+
}

Types/PSEventArgs/PSTypeName.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
System.Management.Automation.PSEventArgs

docs/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## Posh 0.1.8: Posh Formatting
2+
3+
* New Formatting:
4+
* Get-Service shows up in color! (#265)
5+
* Get-Event gets a table formatter (and .EventID, .SourceID, .Time) (#268)
6+
* Get-FileHash groups by algorithm and autosizes (#270)
7+
* Improving Formatting:
8+
* Get-Command now shows Source, not Module (#266) ( thanks @ehmiiz ! )
9+
* Improving Enclosure Support in Links (#272)
10+
11+
---
12+
113
## Posh 0.1.7: Posh Presentation
214

315
* New and Improved Formatting:

0 commit comments

Comments
 (0)