zls is now Get-ZfsItem with zls as an Alias
Modified code to use more 'PowerShell' centric methods, easier on the formatting as table.
This commit is contained in:
parent
9eb99e1581
commit
bb29930d51
|
@ -0,0 +1 @@
|
|||
Get-ZfsItem
|
|
@ -0,0 +1,25 @@
|
|||
[CmdletBinding()]param(
|
||||
[string[]]$Options='name,used,avail,refer,canmount,mounted,mountpoint'
|
||||
)
|
||||
|
||||
$Options = $Options -join ','
|
||||
if( $options -split ',' -notcontains 'name' ) { $options = "name,$Options" }
|
||||
$local:prev = '';
|
||||
zfs list -o $Options |
|
||||
ForEach-Object { $_ -replace ' +',"`t" } |
|
||||
ConvertFrom-Csv -Delimiter "`t" |
|
||||
Where-Object Name -NotMatch '^rpool/var/lib/docker/' |
|
||||
ForEach-Object {
|
||||
$local:o = $_ | Select-Object @{L='-';E={''}},*
|
||||
$local:tmpPrev = $o.Name -replace '^(\w+(\W\w+(\W\w+)?)?).*','$1';
|
||||
if( $tmpPrev -notmatch "^$prev" -and $prev -notin ('','NAME') ) {
|
||||
$o.'-' = "`n-"
|
||||
};
|
||||
$prev = $tmpPrev;
|
||||
if( $o.MOUNTPOINT ) {
|
||||
$o.MOUNTPOINT = $o.MOUNTPOINT -replace '^none$','<none>'
|
||||
}
|
||||
$o
|
||||
} |
|
||||
Format-Table -Wrap
|
||||
|
11
zfs/zls.ps1
11
zfs/zls.ps1
|
@ -1,11 +0,0 @@
|
|||
$local:prev = "";
|
||||
zfs list -o name,used,avail,refer,canmount,mounted,mountpoint $args |
|
||||
grep -v 'docker/' |
|
||||
ForEach-Object {
|
||||
$local:tmpPrev = $_ -replace '^(\w+(\W\w+(\W\w+)?)?).*','$1';
|
||||
if( $tmpPrev -notmatch "^$prev" -and $prev -notin ('','NAME') ) {
|
||||
'-----------------'
|
||||
};
|
||||
$prev = $tmpPrev;
|
||||
$_
|
||||
}
|
Loading…
Reference in New Issue