PowerShell增强

scoop

Scoop是一个包管理系统,它类似于Mac上的Brew,能帮我们方便快捷的管理软件

Set-ExecutionPolicy RemoteSigned -scope CurrentUser
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
scoop -h
scoop install curl sudo jq neovim fzf nvm

文本预测

Set-PSReadLineOption : 找不到与参数名称“PredictionSource”匹配的参数。

出现以上错误,说明 PSReadLine的版本不对,执行以下命令

# 需要用管理员权限
Install-Module PSReadLine -AllowPrerelease -Force

code $PROFILE,打开配置文件

# 设置文本预测
Set-PSReadLineOption -PredictionSource History # 设置预测文本来源为历史记录

git alias

Install-Module -Name git-aliases -RequiredVersion 0.2.3

增强ls功能

# 安装 DirColors
 Install-Module DirColors

配置文件中添加

Import-Module DirColors
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\montys.omp.json" | Invoke-Expression
Import-Module DirColors

$PSReadLineOptions = @{
    EditMode = "Emacs"
    HistoryNoDuplicates = $true
    HistorySearchCursorMovesToEnd = $true
    Colors = @{
        Command            = '#F0C674'
        # Number             = 'DarkGray'
        # Member             = 'DarkGray'
        # Operator           = 'DarkGray'
        # Type               = 'DarkGray'
        # Variable           = 'DarkGreen'
        # Parameter          = 'DarkGreen'
        # ContinuationPrompt = 'DarkGray'
        # Default            = 'DarkGray'
        InlinePrediction = '#707880'
    }
}
Set-PSReadLineOption @PSReadLineOptions
Set-PSReadLineOption -PredictionSource History