Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How history should have been ...
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>history</Name>
<ViewSelectedBy>
<TypeName>Microsoft.PowerShell.Commands.HistoryInfo</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Width>4</Width>
<Alignment>Right</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Duration</Label>
<Width>11</Width>
<Alignment>Right</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>CommandLine</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Id</PropertyName>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
$ts = $_.EndExecutionTime - $_.StartExecutionTime
if($ts.Minutes) {
if($ts.Hours) {
if($ts.Days) {
return "{0:##}d {1:00}h {2:00}m" -f $ts.Days, $ts.Hours, $ts.Minutes
}
return "{0:##}h {1:00}m {2:00}s" -f $ts.Hours, $ts.Minutes, $ts.Seconds
}
return "{0:##}m {1:n3}s" -f $ts.Minutes, ($ts.TotalSeconds - ($ts.Minutes * 60))
}
return "{0:n7}s" -f $ts.TotalSeconds
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
$_.CommandLine.TrimStart() -replace "[\r\n]+", "$([char]0x2026) "
</ScriptBlock>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
<?xml version="1.0" encoding="utf-8" ?>
<Types>
<Type>
<Name>Microsoft.PowerShell.Commands.HistoryInfo</Name>
<Members>
<ScriptProperty>
<Name>Duration</Name>
<GetScriptBlock>
$this.EndExecutionTime - $this.StartExecutionTime
</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
</Types>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.