zoukankan      html  css  js  c++  java
  • PowerShell Core美化

    前置条件

    安装PowerShell CoreVS Code

    安装oh-my-posh posh-git

    以管理员身份打开PowerShell, 执行

    Install-Module oh-my-posh
    Install-Module posh-git
    Install-Module -Name PSReadLine -AllowPrerelease -Force
    

    这里之所以要安装预览版PSReadLine是因为后续的PredictionViewStyle选项是2.2之后才支持的,而目前稳定版是2.1。 powershell core默认内置稳定版PSReadLine, 等下个版本应该就不用手动安装PSReadLine了

    配置profile
    执行 $profile 然后会显示profile文件所在路径
    一般是%UserProfile%\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
    执行code $profile或者code-insiders $profile用vsc打开, 如果没有就会自动创建
    内容如下:
    设置为material主题

    Import-Module posh-git
    Import-Module oh-my-posh
    
    Set-PoshPrompt -Theme material
    
    Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
        param($commandName, $wordToComplete, $cursorPosition)
            dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
                [CompletionResult]::new($_, $_, 'ParameterValue', $_)
            }
    }
    Set-PSReadLineKeyHandler -Key "Ctrl+f" -Function ForwardWord
    Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
    Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
    Set-PSReadLineOption -PredictionSource History -PredictionViewStyle ListView
    

    可以通过命令Get-PoshThemes获取主题列表, 然后替换里边的material主题即可

    效果如下,按上下键切换 自动提示列表来源于历史记录

  • 相关阅读:
    poj 1392 Ouroboros Snake
    poj 1780 Code
    poj 2513 Colored Sticks
    ZOJ 1455 Schedule Problem(差分约束系统)
    poj 3169 Layout (差分约束)
    ZOJ1260/POJ1364国王(King)
    poj 1201/zoj 1508 intervals 差分约束系统
    zoj 2770 Burn the Linked Camp (差分约束系统)
    构造函数和析构函数
    PHP面向对象——静态属性和静态方法
  • 原文地址:https://www.cnblogs.com/dygood/p/15785192.html
Copyright © 2011-2022 走看看