Skip to content

Instantly share code, notes, and snippets.

@cdhunt
Created April 8, 2021 13:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdhunt/62069848ed81f371d4c760b0c5465d09 to your computer and use it in GitHub Desktop.
Save cdhunt/62069848ed81f371d4c760b0c5465d09 to your computer and use it in GitHub Desktop.
Combing FileSystemTypes formats from Powershell-Humanizer and Termincal-Icons
<?xml version="1.0" encoding="utf-8" ?>
<!-- Based on the format.ps1xml file from DirColors
https://github.com/DHowett/DirColors -->
<Configuration>
<SelectionSets>
<SelectionSet>
<Name>FileSystemTypes</Name>
<Types>
<TypeName>System.IO.DirectoryInfo</TypeName>
<TypeName>System.IO.FileInfo</TypeName>
</Types>
</SelectionSet>
</SelectionSets>
<Controls>
<Control>
<Name>FileSystemTypes-GroupingFormat</Name>
<CustomControl>
<CustomEntries>
<CustomEntry>
<CustomItem>
<Frame>
<LeftIndent>4</LeftIndent>
<CustomItem>
<Text AssemblyName="System.Management.Automation" BaseName="FileSystemProviderStrings" ResourceId="DirectoryDisplayGrouping"/>
<ExpressionBinding>
<ScriptBlock>
$_.PSParentPath.Replace("Microsoft.PowerShell.Core\FileSystem::", "")
</ScriptBlock>
</ExpressionBinding>
<NewLine/>
</CustomItem>
</Frame>
</CustomItem>
</CustomEntry>
</CustomEntries>
</CustomControl>
</Control>
</Controls>
<ViewDefinitions>
<View>
<Name>children</Name>
<ViewSelectedBy>
<SelectionSetName>FileSystemTypes</SelectionSetName>
</ViewSelectedBy>
<GroupBy>
<PropertyName>PSParentPath</PropertyName>
<CustomControlName>FileSystemTypes-GroupingFormat</CustomControlName>
</GroupBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Mode</Label>
<Width>7</Width>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>LastWriteTime</Label>
<Width>25</Width>
<Alignment>right</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Length</Label>
<Width>14</Width>
<Alignment>right</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Name</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<Wrap/>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Mode</PropertyName>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
[Humanizer.DateHumanizeExtensions]::Humanize($_.LastWriteTime,$false)
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
if (-not $_.PSIsContainer) { [Humanizer.ByteSizeExtensions]::bytes($_.Length).ToString(0.00)}
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
Terminal-Icons\Format-TerminalIcons $_
</ScriptBlock>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>children</Name>
<ViewSelectedBy>
<SelectionSetName>FileSystemTypes</SelectionSetName>
</ViewSelectedBy>
<GroupBy>
<PropertyName>PSParentPath</PropertyName>
<CustomControlName>FileSystemTypes-GroupingFormat</CustomControlName>
</GroupBy>
<ListControl>
<ListEntries>
<ListEntry>
<EntrySelectedBy>
<TypeName>System.IO.FileInfo</TypeName>
</EntrySelectedBy>
<ListItems>
<ListItem>
<Label>Name</Label>
<ScriptBlock>
Terminal-Icons\Format-TerminalIcons $_
</ScriptBlock>
</ListItem>
<ListItem>
<ScriptBlock>
if (-not $_.PSIsContainer) { [Humanizer.ByteSizeExtensions]::bytes($_.Length).ToString(0.00)}
</ScriptBlock>
</ListItem>
<ListItem>
<ScriptBlock>
[Humanizer.DateHumanizeExtensions]::Humanize($_.CreationTime,$false)
</ScriptBlock>
</ListItem>
<ListItem>
<ScriptBlock>
[Humanizer.DateHumanizeExtensions]::Humanize($_.LastWriteTime,$false)
</ScriptBlock>
</ListItem>
<ListItem>
<ScriptBlock>
[Humanizer.DateHumanizeExtensions]::Humanize($_.LastAccessTime,$false)
</ScriptBlock>
</ListItem>
<ListItem>
<PropertyName>Mode</PropertyName>
</ListItem>
<ListItem>
<PropertyName>LinkType</PropertyName>
</ListItem>
<ListItem>
<Label>Target</Label>
<ScriptBlock>
Terminal-Icons\Format-TerminalIcons $_
</ScriptBlock>
</ListItem>
<!-- <ListItem>
<PropertyName>VersionInfo</PropertyName>
</ListItem> -->
</ListItems>
</ListEntry>
<ListEntry>
<ListItems>
<ListItem>
<Label>Name</Label>
<ScriptBlock>
Terminal-Icons\Format-TerminalIcons $_
</ScriptBlock>
</ListItem>
<ListItem>
<ScriptBlock>
[Humanizer.DateHumanizeExtensions]::Humanize($_.CreationTime,$false)
</ScriptBlock>
</ListItem>
<ListItem>
<ScriptBlock>
[Humanizer.DateHumanizeExtensions]::Humanize($_.LastWriteTime,$false)
</ScriptBlock>
</ListItem>
<ListItem>
<ScriptBlock>
[Humanizer.DateHumanizeExtensions]::Humanize($_.LastAccessTime,$false)
</ScriptBlock>
</ListItem>
<ListItem>
<PropertyName>Mode</PropertyName>
</ListItem>
<ListItem>
<PropertyName>LinkType</PropertyName>
</ListItem>
<ListItem>
<Label>Target</Label>
<ScriptBlock>
Terminal-Icons\Format-TerminalIcons $_
</ScriptBlock>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
<View>
<Name>children</Name>
<ViewSelectedBy>
<SelectionSetName>FileSystemTypes</SelectionSetName>
</ViewSelectedBy>
<GroupBy>
<PropertyName>PSParentPath</PropertyName>
<CustomControlName>FileSystemTypes-GroupingFormat</CustomControlName>
</GroupBy>
<WideControl>
<WideEntries>
<WideEntry>
<WideItem>
<ScriptBlock>
Terminal-Icons\Format-TerminalIcons $_
</ScriptBlock>
</WideItem>
</WideEntry>
<WideEntry>
<EntrySelectedBy>
<TypeName>System.IO.DirectoryInfo</TypeName>
</EntrySelectedBy>
<WideItem>
<ScriptBlock>
Terminal-Icons\Format-TerminalIcons $_
</ScriptBlock>
</WideItem>
</WideEntry>
</WideEntries>
</WideControl>
</View>
</ViewDefinitions>
</Configuration>
@cdhunt
Copy link
Author

cdhunt commented Apr 8, 2021

This requires you have https://github.com/devblackops/terminal-icons and https://github.com/dfinke/PowerShellHumanizer already installed.

Then run Update-FormatData -PrependPath cdhunt.format.ps1xml

@mattcargile
Copy link

Dude! This is Awesome! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment