WindowsTerminal 添加 PowerShell7 与美化

  1. 从GitHub“发布”页面下载需要版本的安装程序

  2. 不同版本的安装方式参见安装各种版本的PowerShell,本文档使用msi进行安装

  3. 在WindowsTerminal的配置文件中增加如下内容,替换下面的安装路径为实际安装位置

    {
        "acrylicOpacity" : 0.5,
        "background" : "#012456",
        "closeOnExit" : true,
        "colorScheme" : "Campbell",
        "commandline" : "D:\\Program Files\\PowerShell\\7\\pwsh.exe",
        "cursorColor" : "#FFFFFF",
        "cursorShape" : "bar",
        "fontFace" : "Sarasa Term SC",
        "fontSize" : 12,
        "guid" : "{90cbdc15-f4fe-49d2-a245-ec066b70845f}",
        "historySize" : 500,
        "icon" : "D:\\Program Files\\PowerShell\\7\\assets\\Powershell_av_colors.ico",
        "name" : "PowerShell 7",
        "padding" : "0, 0, 0, 0",
        "snapOnInput" : true,
        "startingDirectory" : "%USERPROFILE%",
        "useAcrylic" : false
    },
    
  4. 完成添加后保存,在WindowsTerminal中就可以看见PowerShell 7了,如下图所示


    添加完成效果
  5. 启动PowerShell 7,执行Get-PSRepository,若InstallationPolicy显示为Untrusted,则执行Set-PSRepository -Name PSGallery -InstallationPolicy Trusted,如下图所示


    设置完成效果
  6. 执行如下命令安装插件

    • Install-Module posh-git -Scope CurrentUser
    • Install-Module oh-my-posh -Scope CurrentUser
  7. 执行如下命令启用提示并设置主题,更多主题请点击

    • Set-Prompt
    • Set-Theme Agnoster
  8. 执行如下命令生成配置文件,更多配置文件请点击

    if (!(Test-Path -Path $PROFILE ))
    { New-Item -Type File -Path $PROFILE -Force }
    
  9. 使用记事本打开配置文件,并添加如下内容

    Import-Module posh-git
    Import-Module oh-my-posh
    Set-Theme Paradox
    
  10. 最终效果如下所示


    最终效果
  11. 跟多WindowsTerminal配色,请点击

你可能感兴趣的:(WindowsTerminal 添加 PowerShell7 与美化)