-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCustomPSUtils.format.ps1xml
More file actions
106 lines (97 loc) · 3.98 KB
/
CustomPSUtils.format.ps1xml
File metadata and controls
106 lines (97 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<SelectionSets>
<SelectionSet>
<Name>FileSystemTypes</Name>
<Types>
<TypeName>System.IO.DirectoryInfo</TypeName>
<TypeName>System.IO.FileInfo</TypeName>
</Types>
</SelectionSet>
</SelectionSets>
<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>10</Width>
<Alignment>right</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Name</Label>
<Alignment>Left</Alignment>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<Wrap/>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Mode</PropertyName>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
[String]::Format("{0,10} {1,8}", $_.LastWriteTime.ToString("d"), $_.LastWriteTime.ToString("t"))
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Length</PropertyName>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
$name = $_.Name
if(-not($global:SuppresPSUtilsColoring)) {
$regexOptions = ([System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
$executables = @('exe', 'bat', 'cmd', 'py', 'pl', 'ps1', 'psm1', 'vbs', 'rb', 'reg', 'fsx')
$compresseds = @('zip', 'tar', 'gz', '[rjw]ar', 'arj', 'tgz', 'gz')
$texts = @('txt', 'cfg', 'conf', 'ini', 'csv', 'log', 'xml', 'java', 'c(pp)?', 'fs', 'html?')
$executableRegex = New-Object regex("\.($([string]::Join('|', $executables)))`$", $regexOptions)
$compressedRegex = New-Object regex("\.($([string]::Join('|', $compresseds)))`$", $regexOptions)
$textRegex = New-Object regex("\.($([string]::Join('|', $texts)))`$", $regexOptions)
$directoryColor = "$([char](27))[34;1m"
$executableColor = "$([char](27))[32;1m"
$compressedColor = "$([char](27))[31;1m"
$textColor = "$([char](27))[33;1m"
$resetColor = "$([char](27))[0m"
if ($_ -is [System.IO.DirectoryInfo]) {
$name = "$directoryColor$name/$resetColor"
}
elseif ($compressedRegex.IsMatch($_.Name)) {
$name = "$compressedColor$name$resetColor"
}
elseif ($executableRegex.IsMatch($_.Name)) {
$name = "$executableColor$name*$resetColor"
}
elseif ($textRegex.IsMatch($_.Name)) {
$name = "$textColor$name$resetColor"
}
}
$name
</ScriptBlock>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>