Last active
November 18, 2023 04:39
-
-
Save ekishouTV/af228c224accb8cca4da18fa01459257 to your computer and use it in GitHub Desktop.
scoop-du: List directory usage - apps, buckets, cache, modules, persist and shims
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: scoop du [options] | |
# Summary: List directory usage - apps, buckets, cache, modules, persist and shims | |
# Help: 'scoop du' List all (apps, buckets, cache, modules, persist and shims) . | |
# | |
# Options: | |
# -a, --apps Breakdown of apps | |
# -b, --buckets Breakdown of buckets | |
# -c, --cache Breakdown of cache | |
# -m, --modules Breakdown of modules | |
# -p, --persist Breakdown of persist | |
# -s, --shims Breakdown of shims | |
. "$PSScriptRoot\..\apps\scoop\current\lib\getopt.ps1" | |
$opt, $err = getopt $args 'abcmps' 'apps', 'buckets', 'cache', 'modules', 'persist', 'shims' | |
Update-FormatData "$PSScriptRoot\scoop-du.ps1xml" | |
filter measureDirectorySize { | |
ForEach-Object { | |
[PSCustomObject]@{ | |
Name = $((Split-Path $_.FullName -Parent).Split('\') | Select-Object -Last 1) + '\' + $_.Name; | |
Size = [Math]::Round( | |
( | |
Get-ChildItem -Recurse -Force $_.FullName | Measure-Object -ErrorAction SilentlyContinue -Sum Length | |
).Sum / [Math]::Pow(1024, 3), | |
2 | |
) | |
} | |
} | |
} | |
if ($opt.Count -eq 0) { | |
Get-ChildItem ~\scoop\ | measureDirectorySize | Add-Member -TypeName 'ScoopDu' -PassThru | |
} | |
else { | |
$directory_map = [PSCustomObject]@{ | |
a = 'apps' | |
b = 'buckets' | |
c = 'cache' | |
m = 'modules' | |
p = 'persist' | |
s = 'shims' | |
apps = 'apps' | |
buckets = 'buckets' | |
cache = 'cache' | |
modules = 'modules' | |
persist = 'persist' | |
shims = 'shims' | |
} | |
$opt.Keys | Sort-Object | ForEach-Object { Get-ChildItem ~\scoop\$($directory_map.$_) } ` | |
| measureDirectorySize | Add-Member -TypeName 'ScoopDu' -PassThru | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Configuration> | |
<ViewDefinitions> | |
<View> | |
<Name>ScoopDuType</Name> | |
<ViewSelectedBy> | |
<TypeName>ScoopDu</TypeName> | |
</ViewSelectedBy> | |
<TableControl> | |
<TableHeaders> | |
<TableColumnHeader> | |
<Label>Name</Label> | |
<Width>100</Width> | |
<Alignment>left</Alignment> | |
</TableColumnHeader> | |
<TableColumnHeader> | |
<Label>Size</Label> | |
<Width>7</Width> | |
<Alignment>right</Alignment> | |
</TableColumnHeader> | |
</TableHeaders> | |
<TableRowEntries> | |
<TableRowEntry> | |
<TableColumnItems> | |
<TableColumnItem> | |
<PropertyName>Name</PropertyName> | |
</TableColumnItem> | |
<TableColumnItem> | |
<PropertyName>Size</PropertyName> | |
</TableColumnItem> | |
</TableColumnItems> | |
</TableRowEntry> | |
</TableRowEntries> | |
</TableControl> | |
</View> | |
</ViewDefinitions> | |
</Configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: