0 效果预览

1 安装一个 NERD FONTS 字体

网址:Nerd Fonts - Iconic font aggregator, glyphs/icons collection, & fonts patcher --- 书字体 - 标志性字体聚合器,字形/图标集合和字体补丁器 这个网址可以渲染一部分字体以供浏览:https://www.programmingfonts.org/

里面找一个喜欢的就行, 我用的这个: image.png

https://github.com/ryanoasis/nerd-fonts/releases/download/v2.3.3/FiraCode.zip

2 安装 Clink

Overview | Clink --- 概述 |碰杯 (chrisant996.github.io)

GitHub:https://github.com/chrisant996/clink/releases/tag/v1.4.23

下载 exe 文件直接安装即可, 会自动配置到cmd中 image.png

Clink 的特性可以查看这个网站, 支持超久的历史指令记录 Clink v1.4.23 (chrisant996.github.io)

如图所示: image.png

3 配置 starship 启动

找到 Lua 脚本文件 image.png

创建名为 starship.lua 的文件, 并在里面加入一行代码:

load(io.popen('starship init cmd'):read("*a"))()

保存即可, 重启CMD就能看见效果:

在 PowerShell 中安装 Chocolatey 包管理工具:

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

然后用管理员身份运行 powershell, 安装 oh-my-posh

cinst oh-my-posh -y

接着去官方的主题网站找个喜欢的下载下来Themes | Oh My Posh --- 主题 |哦,我的波什 找好之后会是一个json文件, 放到这个目录即可, 里面也自带了很多的主题

C:\Program Files (x86)\oh-my-posh\themes

下载好后去 powershell 里输入 $profile 查看配置文件地址, 如果不存在文件就新建一个。插入这一行代码即可:

oh-my-posh --init --shell pwsh --config 主题路径 | Invoke-Expression

主题路径就是你想应用的主题在本地的绝对路径。如:

oh-my-posh --init --shell pwsh --config "C:\Program Files (x86)\oh-my-posh\themes\1_shell.omp.json" | Invoke-Expression

之后就重启powershell, 如果出现这个情况, 说明执行策略为 Restricted 禁止脚本运行, 需要修改一下。 image.png

输入该命令查看执行策略:

get-executionpolicy

解决方法为该命令, 把执行策略设置为  remotesigned

 set-executionpolicy remotesigned

之后再重启就可以实现 image.png

但这个版权信息有点烦人, 关闭的话需要右键进入设置, 添加启动参数 -Nologoimage.png