pwsh里对ls的功能增强

给pwsh中的ls这类功能新增的几个函数

function l {
    Get-ChildItem  $args | Select-Object -ExpandProperty name
}

# 列出文件和文件夹,同时显示文件大小以友好的单位
function ll {
    Get-ChildItem | ForEach-Object {
        $size = $_.Length
        $sizeUnit = "Bytes"
        if ($size -ge 1GB) {
            $size = $size / 1GB
            $sizeUnit = "GB"
        }
        elseif ($size -ge 1MB) {
            $size = $size / 1MB
            $sizeUnit = "MB"
        }
        elseif ($size -ge 1KB) {
            $size = $size / 1KB
            $sizeUnit = "KB"
        }
        [PSCustomObject]@{
            Mode = $_.Mode
            LastWriteTime = $_.LastWriteTime
            Size = "{0:N2} {1}" -f $size, $sizeUnit
            Name = $_.Name
        }
    } | Format-Table
}

# 列出文件和文件夹,同时显示文件大小以友好的单位 显示完整路径
function lspath {
    Get-ChildItem | ForEach-Object {
        $size = $_.Length
        $sizeUnit = "Bytes"

        if ($size -ge 1GB) {
            $size = $size / 1GB
            $sizeUnit = "GB"
        }
        elseif ($size -ge 1MB) {
            $size = $size / 1MB
            $sizeUnit = "MB"
        }
        elseif ($size -ge 1KB) {
            $size = $size / 1KB
            $sizeUnit = "KB"
        }

        [PSCustomObject]@{
            Mode = $_.Mode
            LastWriteTime = $_.LastWriteTime
            Size = "{0:N2} {1}" -f $size, $sizeUnit
            Name = $_.FullName  # 使用 FullName 显示完整路径
        }
    } | Format-Table -AutoSize
}

function lsd {
    [CmdletBinding()]
    param(
        [Parameter(ValueFromRemainingArguments = $true)]
        [string[]]$filePaths
    )

    if ($filePaths -eq $null -or $filePaths.Count -eq 0) {
        $filePaths = (Get-ChildItem $PWD).FullName
    }

    $result = foreach ($filePath in $filePaths) {
        $file = Get-Item $filePath

        [PSCustomObject]@{
            Mode = $file.Mode
            File = $file.Name
            CreationTime = $file.CreationTime
            LastWriteTime = $file.LastWriteTime
            LastAccessTime = $file.LastAccessTime
        }
    }

    $result | Format-Table
}

function lspipe {
    ls \\.\pipe\
    ##(get-childitem \\.\pipe\).FullName
}