pwsh个人配置

Import-Module PSReadLine

Set-PSReadlineOption -EditMode Emacs
Set-PSReadLineOption -PredictionSource History              # 设置预测文本来源为历史记录
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete    # 设置 Tab 键菜单补全
Set-PSReadLineKeyHandler -Key UpArrow -ScriptBlock {        # 设置向上键为后向搜索历史记录
    [Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchBackward()
    [Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}
Set-PSReadLineKeyHandler -Key DownArrow -ScriptBlock {      # 设置向下键为前向搜索历史纪录
    [Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchForward()
    [Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}

function alpine { wsl -d Alpine -e $args }
function archlinux { wsl -d Arch -e $args }
function mklink { cmd /C mklink $args }

function wslpath {
    $dArgs = @()
    foreach($i in $args){
        $i = $i | sed -e 's#^\(.\):#/mnt/\L\1#' -e 's#\\#/#g'
        $i = $i -replace " ", "\ "
        $i = $i -replace "\$", "\$"
        $dArgs += $i
    }
    $wArgs = $dArgs -join ' '
    return $wArgs
}

Remove-Item alias:ls -Force
function exa { alpine bash -c "exa -gh --time-style=iso --group-directories-first $(wslpath $args)" }
function ls { exa --icons $args }
function ll { exa --icons -l $args }
function l { exa --icons -l $args }
function la { exa --icons -a $args }
function lla { exa --icons -la $args }
function lt { exa --icons --tree $args }
function lat { exa --icons --tree -a $args }
function llt { exa --icons --tree -l $args }
function llat { exa --icons --tree -la $args }

function su { sudo pwsh.exe -nologo }

function setproxy {
    $env:HTTP_PROXY="http://127.0.0.1:1080"
    $env:HTTPS_PROXY="http://127.0.0.1:1080"
}

function unsetproxy {
    $env:HTTP_PROXY=""
    $env:HTTPS_PROXY=""
}

# only pwsh
oh-my-posh.exe --init --shell pwsh --config ~\Documents\PowerShell\config.omp.json | Invoke-Expression
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务