format.ps1xml support + fixes

+ Get-DockerProcess modified to display volume mappings (Binds) as well
  as docker-compose project names.
+ Reload-MyScripts will look for *.format.ps1xml files in the profile.d
  directory and load the format data from it.
+ Get-DockerProcess output is typed and a TypeData.format.ps1xml file
  was added to the package
+ Added _ll alias for easy posix ls -la output.
+ config.files.json modified for better neovim support.
This commit is contained in:
lksz 2021-05-27 11:48:00 -04:00
parent fefb5e2572
commit 84d533a210
5 changed files with 81 additions and 17 deletions

View file

@ -1,12 +1,31 @@
#[CmdletBinding(SupportsShouldProcess)]param(
[CmdletBinding()]param([string[]]$MatchName,[string[]]$OrderBy,[switch]$PassThru,[string[]]$MatchAny)
$local:result = $(docker ps --format='{{ .Image }}\t{{ .Names }}\t{{ .Status }}\t{{ .Ports }}' |
$local:containers = [ordered]@{}
$(docker ps -q) |
ForEach-Object {
$local:l = $_ -split '\t';
[PSCustomObject]([ordered]@{Image=$l[0];Name=$l[1];Status=$l[2];Ports=$l[3] -replace ', ',"`n"})
} ) | Sort-Object Name
$local:tmp = docker inspect $_ | ConvertFrom-Json;
$local:tmpObj = [PSCustomObject]([ordered]@{
Name=$tmp.Name.Substring(1)
Project=$tmp.Config.Labels.'com.docker.compose.project'
Service=$tmp.Config.Labels.'com.docker.compose.service'
Status=$tmp.State.Status
Image=$tmp.Config.Image
Ports=$(
$tmp.HostConfig.PortBindings |
Get-Member -type NoteProperty | Select-Object -ExpandProperty Name |
ForEach-Object {
"$($tmp.HostConfig.PortBindings."$_".HostPort)/$_"
}
)
Binds= $tmp.HostConfig.Binds
raw = $tmp
})
$tmpObj.PSObject.TypeNames.Insert(0,"DockerContainersOutput")
$containers[$tmpObj.Name]=$tmpObj
}
$local:result = $containers.Values | Sort-Object Name
if( $MatchName ) {
$result = $result | Where-Object Name -match $($MatchName -join '|')
}
@ -19,6 +38,6 @@ if( $OrderBy ) {
$result = $result | Sort-Object $OrderBy
}
if( $PassThru ) { return $result }
$result | Format-Table -Wrap
#if( $PassThru ) { return $result }
$result #| Format-Table -Wrap