Windows Terminal + PowerShell Core 美化

最终效果

安装 Windows Terminal

应用商店中搜索, 下载

下载 PowerShell Core

https://github.com/PowerShell/PowerShell/releases

字体

Sarasa[更纱黑体]

https://github.com/be5invis/Sarasa-Gothic

这里是搬运地址:
https://download.csdn.net/download/MAIMIHO/12490128

安装 Sarasa Term SC

Windows terminal Setting

打开 Windows terminal 设置, 替换如下, 注意里面的路径替换为自己的

{
  "$schema": "https://aka.ms/terminal-profiles-schema",
  "defaultProfile": "{195e5e70-802f-4ae6-a4e6-57eff2b90258}",
  "copyOnSelect": false,
  "copyFormatting": false,
  "theme": "dark",
  "launchMode": "maximized",
  "snapToGridOnResize": false,
  "profiles": {
    "defaults": {
      "colorScheme": "Dracula",
      //背景透明度,
      "acrylicOpacity": 0.8,
      // 启用毛玻璃,
      "useAcrylic": true,
      //背景图片,
      "backgroundImage": "你的背景图片路径",
      //图片透明度,
      "backgroundImageOpacity": 0.5,
      //填充模式,
      "backgroundImageStretchMode": "fill",
      //字体,
      "fontFace": "Sarasa Term SC",
      //文字大小,
      "fontSize": 14,
      //光标颜色,
      "cursorColor": "#FFFFFF",
      //光标形状,
      "cursorShape": "bar",
      "startingDirectory": ".",
      "antialiasingMode": "cleartype"
    },
    "list": [
      {
        "guid": "{195e5e70-802f-4ae6-a4e6-57eff2b90258}",
        "name": "PowerShell Core",
        "icon": "C:\\Dev\\PowerShell\\assets\\Powershell_av_colors.ico",
        "commandline": "C:\\Dev\\PowerShell\\pwsh.exe -nologo",
        "hidden": false
      },
      {
        "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
        "name": "Windows PowerShell",
        "commandline": "powershell.exe",
        "hidden": false
      },
      {
        "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
        "name": "命令提示符",
        "commandline": "cmd.exe",
        "hidden": false
      },
      {
        "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
        "hidden": false,
        "name": "Azure Cloud Shell",
        "source": "Windows.Terminal.Azure"
      }
    ]
  },
  "schemes": [
    {
      "name": "Dracula",
      "background": "#272935",
      "black": "#21222C",
      "blue": "#BD93F9",
      "cyan": "#8BE9FD",
      "foreground": "#F8F8F2",
      "green": "#50FA7B",
      "purple": "#FF79C6",
      "red": "#FF5555",
      "white": "#F8F8F2",
      "yellow": "#FFB86C",
      "brightBlack": "#6272A4",
      "brightBlue": "#D6ACFF",
      "brightCyan": "#A4FFFF",
      "brightGreen": "#69FF94",
      "brightPurple": "#FF92DF",
      "brightRed": "#FF6E6E",
      "brightWhite": "#F8F8F2",
      "brightYellow": "#FFFFA5"
    }
  ],
  "keybindings": [
    {
      "command": {
        "action": "copy",
        "singleLine": false
      },
      "keys": "ctrl+c"
    },
    {
      "command": "paste",
      "keys": "ctrl+v"
    },
    {
      "command": "find",
      "keys": "ctrl+shift+f"
    },
    {
      "command": {
        "action": "splitPane",
        "split": "auto",
        "splitMode": "duplicate"
      },
      "keys": "alt+shift+d"
    }
  ]
}

权限设置

##允许执行脚本
set-executionpolicy remotesigned

安装模块

遇到提示统一选 Y

Install-Module -Name PSReadLine -AllowPrerelease -Force
Install-Module git-aliases -AllowClobber
Install-Module posh-git
Install-Module oh-my-posh
Install-Module DirColors

保存配置

打开配置文件

code $PROFILE (notpad $PROFILE) # VSCode or 记事本打开

输入以下 -> 保存

Import-Module DirColors
Import-Module posh-git
Import-Module oh-my-posh
Import-Module git-aliases -DisableNameChecking
Set-Theme PowerLine

#-------------------------------  Set Hot-keys BEGIN  -------------------------------
# 设置 Tab 键补全
# Set-PSReadlineKeyHandler -Key Tab -Function Complete

# 设置 Tab 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key "Tab" -Function MenuComplete

# 设置 Ctrl+d 为退出 PowerShell
Set-PSReadlineKeyHandler -Key "Ctrl+d" -Function ViExit

# 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo

# 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward

# 设置向下键为前向搜索历史纪录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

# 一些PSReadline配置
$PSReadLineOptions = @{
    EditMode = "Windows"
    HistoryNoDuplicates = $true
    HistorySearchCursorMovesToEnd = $true
    ShowToolTips = $true
    Colors = @{
        # 提示文字颜色,原来的颜色太浅了,我这里换了
        Prediction = '#888888'
    }
}
Set-PSReadLineOption @PSReadLineOptions

#-------------------------------  Set Hot-keys END    -------------------------------

加入右键菜单

win+r 输入 regedit 计算机\HKEY_CLASSES_ROOT\Directory\Background\shell

shell 下新建 wt

wt 默认Open Windows Terminal here

wt 下 新建 字符串值 IconC:\Dev\PowerShell\assets\Powershell_av_colors.ico

wt 下 新建 commandC:\Users\[你的用户名]\AppData\Local\Microsoft\WindowsApps\wt.exe


参考

https://github.com/dracula/windows-terminal

https://docs.microsoft.com/zh-cn/windows/terminal/

https://www.chuchur.com/article/windows-terminal-beautify

https://zhuanlan.zhihu.com/p/137595941

https://blog.csdn.net/zaoandly/article/details/106415873

  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值