概述说明

Windows终端美化方案

Starship

相关链接如下:

项目 数据
Github主页: https://github.com/starship/starship
官网: https://starship.rs/zh-CN/
指南: https://starship.rs/zh-CN/guide/

安装说明

详细安装说明.

安装字体

小提示

字体网站:nerdfonts
推荐字体:Fira Code Nerd Font

打开字体下载页面,然后搜索FiraCode
../../Files/PixPin_2025-08-07_09-37-08.png

下载压缩包解压后,会有20个左右的字体文件,不需要全部安装,字体说明:

  • Mono 后缀(等宽字体):所有字符(包括字母、数字、符号)宽度相同,适合编程和终端使用
  • Propo 后缀(比例字体):字符宽度根据字形自动调整(如 i 较窄,W 较宽),更接近日常阅读字体。
    那么因为我们是为了终端使用,就安装带有Mono后缀的字体.

安装程序

安装完字体后就可以安装Starship本体了.可以到Github发布页下载安装程序安装,也可以使用命令安装:

winget install --id Starship.Starship

配置文件

创建Starship的配置文件:

# 创建 .config 目录(如果不存在)
New-Item -ItemType Directory -Force -Path "$HOME\.config"

# 创建 starship.toml 文件
New-Item -ItemType File -Force -Path "$HOME\.config\starship.toml"

配置文件路径:
../../Files/PixPin_2025-08-20_04-52-04.png

启用功能

安装完毕后,需要手动启用Starship,不同的终端启用方式不同.

Powershell

这里以Windows终端+Powershell7演示.启用方法就是在Powershell的配置文件中追加:

Invoke-Expression (&starship init powershell)
快速完成,执行完这行代码,后面的就不用再执行,可以阅读下了解原理
if (!(Test-Path $PROFILE)) { New-Item -Force -Path $PROFILE | Add-Content -Value "# 启用 Starship`nInvoke-Expression (&starship init powershell)" } else { Add-Content -Path $PROFILE -Value "`n# 启用 Starship`nInvoke-Expression (&starship init powershell)" }
  • 手动执行:
    首先获取Powershell配置文件路径:
$PROFILE

默认情况下,配置文件路径如下,但是实际上可能没有创建这个文件,那么就需要我们创建:

~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

可以检测配置文件是否存在(返回False说明文件不存在):

Test-Path -Path (Split-Path $PROFILE -Parent)

创建 Documents\PowerShell 目录(如果不存在):

New-Item -ItemType Directory -Force -Path (Split-Path $PROFILE -Parent)

创建配置文件(如果不存在)

New-Item -ItemType File -Force -Path $PROFILE

编辑配置文件:

notepad $PROFILE

打开配置文件以后,在文件末尾追加:

# 启用 Starship
Invoke-Expression (&starship init powershell)

然后关闭Powershell再重新打开即可.

简单配置

官方配置指南:点击浏览

打开配置文件,可以加入一些简单配置:

# 根据 schema 提供自动补全
"$schema" = 'https://starship.rs/config-schema.json'

# 在提示符之间插入空行
add_newline = false

使用预设

官方推荐了一些社区分享预设:点击查看

然后根据官方提示,设置预设即可,但是要注意,~/.config的格式可能会找不到路径,在Windows下,可以改成如下格式:

starship preset pastel-powerline -o "$HOME\.config\starship.toml"

../../Files/PixPin_2025-08-07_10-09-40.png

停用方法

要嘛直接卸载,或者关闭某些终端的配置文件配置,以Powershell为例,打开配置文件,删除启用命令:

notepad $PROFILE

打开配置文件以后,删除相关命令即可.

oh-my-posh

相关链接如下:

项目 数据
Github主页: https://github.com/JanDeDobbeleer/oh-my-posh
官网: https://ohmyposh.dev/
主题: https://ohmyposh.dev/docs/themes

安装说明

官方安装说明:点击访问
或者在Github发布页下载安装.

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。