终端精致小玩具 - Ghostty
- 内容介绍
- 文章标签
- 相关推荐
Ghostty + Zsh + Starship 终端配置记录
日期:2025-12-12
参考帖子:Claude Code 终端工具 - #44,来自 Lucas_Men
一、背景
根据帖子中的终端优化方案,对 Ghostty 终端、Zsh shell 和 Starship 提示符进行配置优化。
帖子方案总结
| 组件 | 选择 |
|---|---|
| 终端 | Ghostty |
| Shell | Zsh (不用 oh-my-zsh) |
| 提示符 | Starship |
| 字体 | Maple Mono Normal NF CN |
| 主题 | GitHub Dark Dimmed |
| Zsh 插件 | zsh-completions, zsh-autosuggestions, zsh-syntax-highlighting |
完成效果图
image-202512121132283311692×1144 155 KB
image-202512121134108452750×1100 243 KB
image-202512151038223992228×1820 629 KB
二、已完成的配置
字体安装
Maple Mono 字体(通过 Homebrew):
# Maple Mono NF CN(推荐,包含 Nerd Font 图标 + 中文支持)
brew install --cask font-maple-mono-nf-cn
# 其他可选版本
brew install --cask font-maple-mono # 基础版
brew install --cask font-maple-mono-nf # Nerd Font 版(无中文)
参考:Maple Mono 官方仓库
2.1 Ghostty 配置
配置文件位置:~/Library/Application Support/com.mitchellh.ghostty/config
配置样例:
# ========== 字体设置 ==========
# 主字体:Maple Mono NF CN
font-family = Maple Mono NF CN
font-size = 17
# 行高设置(Maple Font 官方推荐 1.8 行高,实测最佳值为 30%)
adjust-cell-height = 25%
# 启用 Maple Mono 连字和字体特性(官方推荐配置)
# calt: 基本连字 | zero: 带点的零 | cv01: 去除间隙
# ss01: 分离等号 | ss02: 分离比较符 | ss07: 强制 >> 连字 | ss08: 双箭头
font-feature = calt, cv01, cv03, ss01, ss02, ss03
# 字体粗细(让字体更粗,类似 Tabby 600/700 配置)
font-thicken = true
# ========== 主题设置 ==========
theme = GitHub Dark Dimmed
# ========== 窗口尺寸 ==========
# 设置窗口初始大小(以字符为单位)
window-width = 175
window-height = 45
# 记住窗口位置和大小
window-save-state = always
# ========== 光标设置 ==========
# 光标样式:block(粗方块光标,类似 Tabby)
cursor-style = block
# 光标闪烁
cursor-style-blink = true
# 光标颜色(使用明亮的橙色,更醒目)
cursor-color = #ff9e64
# 光标下的文本颜色
cursor-text = #1a1b26
# ========== 窗口外观 ==========
# 窗口内边距
window-padding-x = 8
window-padding-y = 8
# 窗口装饰样式(macOS)- tabs 样式支持标签栏
macos-titlebar-style = tabs
# 保持窗口阴影
macos-window-shadow = true
# ========== 其他优化 ==========
# 背景略微透明(可选,1.0 为完全不透明)
background-opacity = 0.97
# 滚动缓冲区大小(单位:字节)
# 适合 Claude Code 等长对话应用
scrollback-limit = 200000000
# 在输入时隐藏鼠标
mouse-hide-while-typing = true
# ========== Shell Integration ==========
# 启用 shell 集成,但明确禁用 cursor 特性(避免覆盖我们的光标设置)
shell-integration = zsh
shell-integration-features = no-cursor,title
keybind = shift+enter=text:\x1b\r
keybind = ctrl+enter=text:\\\r
当前配置:
- 主题:GitHub Dark Dimmed(用户偏好,未更换为 Catppuccin)
- 字体:Maple Mono NF CN @ 17pt
- 启用连字特性:
calt, cv01, cv03, ss01, ss02, ss03 - 字体加粗:
font-thicken = true - 光标:block 样式,橙色闪烁
- 透明度:97%
- 滚动缓冲:200MB
Ghostty 内置主题:可通过 ghostty +list-themes 查看。
预览主题命令:
open -na Ghostty.app --args --theme="主题名"
2.2 Zsh 插件配置
已安装(通过 Homebrew):
brew install starship zsh-autosuggestions zsh-syntax-highlighting zsh-completions
配置文件:~/.zshrc
新增内容:
# ══════════════════════════════════════════════════════════════════════
# 2. 命令补全
# ══════════════════════════════════════════════════════════════════════
# Zsh 补全系统增强
if type brew &>/dev/null; then
FPATH="$(brew --prefix)/share/zsh-completions:$FPATH"
FPATH="$(brew --prefix)/share/zsh/site-functions:$FPATH"
fi
# 初始化补全系统(必须在设置 FPATH 之后、加载补全脚本之前)
autoload -Uz compinit
# 使用缓存加速,每天只重建一次
if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then
compinit
else
compinit -C
fi
# ══════════════════════════════════════════════════════════════════════
# 5. Zsh 插件
# ══════════════════════════════════════════════════════════════════════
# zsh-autosuggestions - 根据历史命令自动补全建议(灰色提示)
if [ -f "$(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh" ]; then
source "$(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
fi
# zsh-syntax-highlighting - 命令语法高亮
if [ -f "$(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]; then
source "$(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
fi
# ══════════════════════════════════════════════════════════════════════
# 6. 提示符主题 (Starship)
# ══════════════════════════════════════════════════════════════════════
if command -v starship &>/dev/null; then
eval "$(starship init zsh)"
fi
权限修复(解决 compinit insecure directories 警告):
chmod go-w /opt/homebrew/share
chmod -R go-w /opt/homebrew/share/zsh
2.3 Starship 配置
配置文件位置:~/.config/starship.toml
当前配置(极简风格):
# Starship 极简风格配置
format = """
$os\
$username\
$directory\
$git_branch\
$git_status\
$python\
$conda\
$time\
$line_break\
$character"""
command_timeout = 1000
[os]
disabled = false
format = "[$symbol]($style) "
style = "bold white"
[os.symbols]
Macos = "" # 注意:需用 Python 写入,见下方说明
[username]
disabled = false
show_always = true
format = "[$user]($style) "
style_user = "bold cyan"
[directory]
format = "[$path]($style)[$read_only]($read_only_style) "
style = "bold blue"
truncation_length = 3
[git_branch]
format = "[$symbol$branch]($style) "
symbol = " "
style = "bold purple"
[git_status]
format = "([$all_status$ahead_behind]($style) )"
style = "bold yellow"
conflicted = " " # 需用 Python 写入
ahead = "⇡${count}"
behind = "⇣${count}"
diverged = "⇕⇡${ahead_count}⇣${behind_count}"
untracked = " ${count} " # 需用 Python 写入
stashed = " ${count} " # 需用 Python 写入
modified = " ${count} " # 需用 Python 写入
staged = " ${count} " # 需用 Python 写入
renamed = " ${count} " # 需用 Python 写入
deleted = " ${count} " # 需用 Python 写入
[python]
format = "[$symbol($virtualenv )]($style)"
symbol = " "
style = "bold yellow"
[conda]
format = "[$symbol$environment]($style) "
symbol = " "
style = "bold green"
ignore_base = false
[time]
disabled = false
format = "[$time]($style) "
style = "dimmed white"
time_format = "%H:%M"
[character]
success_symbol = "[❯](bold green)"
error_symbol = "[❯](bold red)"
三、启动时间对比
| 状态 | 时间 | 说明 |
|---|---|---|
| 配置前 | ~130ms | 基础配置 |
| 配置后(无系统信息工具) | ~260ms | 插件 + Starship |
| + fastfetch | ~280ms | 推荐(仅增加 20ms) |
| + neofetch | ~460ms | 不推荐(增加 200ms) |
测试命令:
for i in 1 2 3; do time zsh -i -c exit; done
四、已解决问题
4.1 苹果图标不显示(已解决)
现象:Starship 的 [os] 模块或硬编码方式无法正常显示苹果图标。
根本原因:
Nerd Font 字符(如苹果图标 U+F179)属于 Unicode 私有使用区域(PUA),在以下场景会丢失:
- 编辑器保存时过滤 PUA 字符
- 复制粘贴时字符丢失
- Bash heredoc / echo 重定向时字符被丢弃
解决方案:使用 Python 写入 Nerd Font 字符
# 写入 os.symbols 的苹果图标
python3 -c "
with open('/Users/lostsheep/.config/starship.toml', 'r') as f:
content = f.read()
content = content.replace('Macos = \"\"', 'Macos = \"\uf179\"')
with open('/Users/lostsheep/.config/starship.toml', 'w') as f:
f.write(content)
"
验证方法:
# 检查字符是否正确写入(应显示 ef 85 b9)
grep "Macos" ~/.config/starship.toml | xxd
# 测试 os 模块输出
starship module os
4.2 Git Status 图标配置(已解决)
现象:git_status 模块使用文本符号(如 !, ?)显示,希望改为 Nerd Font 图标。
解决方案:使用 Python 写入 Nerd Font 图标
python3 -c "
with open('/Users/lostsheep/.config/starship.toml', 'r') as f:
content = f.read()
# git_status 图标替换
replacements = {
'modified = \"!\${count}\"': 'modified = \"\uf044 \${count} \"', # pencil
'untracked = \"?\${count}\"': 'untracked = \"\uf016 \${count} \"', # file-o
'staged = \"+\${count}\"': 'staged = \"\uf067 \${count} \"', # plus
'deleted = \"✘\${count}\"': 'deleted = \"\uf014 \${count} \"', # trash
'renamed = \"»\${count}\"': 'renamed = \"\uf061 \${count} \"', # arrow-right
'conflicted = \"=\"': 'conflicted = \"\uf071 \"', # warning
'stashed = \"\$\${count}\"': 'stashed = \"\uf187 \${count} \"', # archive
}
for old, new in replacements.items():
content = content.replace(old, new)
with open('/Users/lostsheep/.config/starship.toml', 'w') as f:
f.write(content)
"
图标对照表:
| 状态 | 图标 | Unicode | 名称 |
|---|---|---|---|
| modified | U+F044 | pencil | |
| untracked | U+F016 | file-o | |
| staged | U+F067 | plus | |
| deleted | U+F014 | trash | |
| renamed | U+F061 | arrow-right | |
| conflicted | U+F071 | warning | |
| stashed | U+F187 | archive |
五、可选工具
5.1 Fastfetch(推荐)
为什么选择 Fastfetch?
| 对比项 | Fastfetch | Neofetch |
|---|---|---|
| 执行速度 | 30-40ms | 200-300ms |
| 语言 | C(编译型) | Bash(解释型) |
| 启动影响 | +20ms(几乎无感知) | +200ms(明显卡顿) |
结论:Fastfetch 比 neofetch 快 6-10 倍,对终端启动速度影响极小。
安装
brew install fastfetch
使用
# 直接运行
fastfetch
# 测试性能
time fastfetch
配置自动启动
在 ~/.zshrc 末尾添加:
# ══════════════════════════════════════════════════════════════════════
# 7. 系统信息显示
# ══════════════════════════════════════════════════════════════════════
# fastfetch - 快速显示系统信息(~30ms)
if command -v fastfetch &>/dev/null; then
fastfetch
fi
配置位置:~/.zshrc:181-188(在 Starship 初始化之后)
显示效果
启动终端时自动显示:
- macOS ASCII Logo(彩色渐变)
- 系统版本、内核信息
- 硬件信息(CPU、GPU、内存)
- 显示器配置
- 终端、Shell 信息
- 颜色测试条
自定义配置(可选)
# 生成默认配置文件
fastfetch --gen-config
# 配置文件位置
~/.config/fastfetch/config.jsonc
简化显示示例(只显示核心信息):
在 .zshrc 中修改为:
fastfetch --logo small --structure Title:Separator:OS:Host:Kernel:Uptime:Shell:Terminal:CPU:Memory
性能验证
在 Apple M4 Mac mini 上的实测:
- fastfetch 单独执行:35ms
- 终端启动总时间:280ms(相比无 fastfetch 的 260ms 仅增加 20ms)
5.2 Neofetch(不推荐)
性能警告:Neofetch 使用 Bash 脚本实现,启动耗时 200-300ms,会明显拖慢终端启动速度。
推荐使用 Fastfetch 替代(快 6-10 倍,功能相同)。
Neofetch 是一个命令行系统信息工具,可以显示 ASCII 艺术图标和系统信息。
安装:
brew install neofetch
使用:
neofetch
配置苹果图标:
macOS 下 neofetch 默认显示苹果 ASCII 图标,无需额外配置。如需自定义,可编辑配置文件:
# 生成默认配置文件
mkdir -p ~/.config/neofetch
neofetch --print_config > ~/.config/neofetch/config.conf
# 编辑配置
vim ~/.config/neofetch/config.conf
常用配置选项(在 config.conf 中):
# 更换 ASCII 图标(可选:auto, ascii, wallpaper, 或指定图片路径)
image_source="auto"
# 指定使用某个发行版的 ASCII 图标
ascii_distro="macos"
# ASCII 图标颜色(使用 Nerd Font 调色板)
ascii_colors=(2 3 1 1 5 4)
# 隐藏某些信息行
print_info() {
info title
info underline
info "OS" distro
info "Host" model
info "Kernel" kernel
info "Uptime" uptime
info "Packages" packages
info "Shell" shell
info "Terminal" term
info "CPU" cpu
info "GPU" gpu
info "Memory" memory
info cols
}
终端启动时自动显示:
在 ~/.zshrc 末尾添加:
# Neofetch - 启动时显示系统信息
if command -v neofetch &>/dev/null; then
neofetch
fi
注意:
- 不推荐加入
.zshrc,会增加 200-300ms 启动时间 - 建议改用 Fastfetch(快 6-10 倍,功能相同)
- 如需使用,建议仅手动运行
neofetch查看系统信息
六、相关命令速查
Ghostty
# 列出所有主题
ghostty +list-themes
# 预览主题(新窗口)
open -na Ghostty.app --args --theme="主题名"
# 编辑配置
ghostty +edit-config
Starship
# 查看版本
starship --version
# 测试单个模块
starship module os
# 预设配置
starship preset catppuccin-powerline -o ~/.config/starship.toml
Zsh 启动时间
# 测试启动时间
for i in 1 2 3; do time zsh -i -c exit; done
Fastfetch
# 查看版本
fastfetch --version
# 运行并测试性能
time fastfetch
# 生成配置文件
fastfetch --gen-config
# 自定义显示内容
fastfetch --logo small --structure Title:OS:Host:Kernel:CPU:Memory
七、配置文件位置汇总
| 文件 | 路径 |
|---|---|
| Ghostty 配置 | ~/Library/Application Support/com.mitchellh.ghostty/config |
| Zsh 环境变量 | ~/.zshenv (如果你的配置没有使用则不添加) |
| Zsh 私密配置 | ~/.zshenv.local (如果你的配置没有使用则不添加) |
| Zsh 交互式配置 | ~/.zshrc |
| Starship 配置 | ~/.config/starship.toml |
| Fastfetch 配置 | ~/.config/fastfetch/config.jsonc |
| Neofetch 配置 | ~/.config/neofetch/config.conf |
八、参考链接
- Ghostty 官网
- Starship 官方文档
- Fastfetch GitHub
- Neofetch GitHub(已停止维护)
- Maple Mono 字体
- 原帖链接
最后,希望各位佬友都有自己的精致小玩具
网友解答:--【壹】--:
佬 知道咋配置标签页 感觉标签页切换不太明显
image3794×282 75.2 KB
--【贰】--:
怪好看的……但…我觉得我用putty就够了
--【叁】--:
谢谢大佬分享配置!!!
--【肆】--:
哈哈,就是这个字体
--【伍】--:
太强了,大佬!
--【陆】--:
image3490×114 44.4 KB
还能看到啊
--【柒】--:
ghostty可不是小玩具。是基础设施。
--【捌】--:
不错不错! 还是折腾有意思啊!
我折腾 nushell 还没搞清楚一点~ 佬太强了!
--【玖】--:
分屏下的标题怎么解决呢?且之前试了一下,就碰到这个问题,就没再用了。因为到四分屏之后,完全看不到这个终端开的内容是什么了。
--【拾】--:
tql大佬
--【拾壹】--:
tql佬
--【拾贰】--:
牛啊牛啊,
--【拾叁】--:
暴露了我是老登的事实……
--【拾肆】--:
putty 是啥,还没用过呢
--【拾伍】--: Jerry Hou:
我觉得我用putty就够
重量级选手
--【拾陆】--:
应该是看你主题的,我的主题是 GitHub Dark Dimmed 这个,在 macOS26 上的风格是这样的:
image3802×178 29.2 KB
--【拾柒】--:
太强了佬 前几天我还刚摸索问了一个帖子 结果你这边发了更完整的教程了 相遇恨晚
分割线 哈哈没看到开头 刚发现
另外字体用的 Maple Mono Normal NF CN 这个感觉更好看一点
brew install --cask font-maple-mono-normal-nf-cn
--【拾捌】--:
哈哈,有道理
--【拾玖】--:
好看,谢谢佬友分享
Ghostty + Zsh + Starship 终端配置记录
日期:2025-12-12
参考帖子:Claude Code 终端工具 - #44,来自 Lucas_Men
一、背景
根据帖子中的终端优化方案,对 Ghostty 终端、Zsh shell 和 Starship 提示符进行配置优化。
帖子方案总结
| 组件 | 选择 |
|---|---|
| 终端 | Ghostty |
| Shell | Zsh (不用 oh-my-zsh) |
| 提示符 | Starship |
| 字体 | Maple Mono Normal NF CN |
| 主题 | GitHub Dark Dimmed |
| Zsh 插件 | zsh-completions, zsh-autosuggestions, zsh-syntax-highlighting |
完成效果图
image-202512121132283311692×1144 155 KB
image-202512121134108452750×1100 243 KB
image-202512151038223992228×1820 629 KB
二、已完成的配置
字体安装
Maple Mono 字体(通过 Homebrew):
# Maple Mono NF CN(推荐,包含 Nerd Font 图标 + 中文支持)
brew install --cask font-maple-mono-nf-cn
# 其他可选版本
brew install --cask font-maple-mono # 基础版
brew install --cask font-maple-mono-nf # Nerd Font 版(无中文)
参考:Maple Mono 官方仓库
2.1 Ghostty 配置
配置文件位置:~/Library/Application Support/com.mitchellh.ghostty/config
配置样例:
# ========== 字体设置 ==========
# 主字体:Maple Mono NF CN
font-family = Maple Mono NF CN
font-size = 17
# 行高设置(Maple Font 官方推荐 1.8 行高,实测最佳值为 30%)
adjust-cell-height = 25%
# 启用 Maple Mono 连字和字体特性(官方推荐配置)
# calt: 基本连字 | zero: 带点的零 | cv01: 去除间隙
# ss01: 分离等号 | ss02: 分离比较符 | ss07: 强制 >> 连字 | ss08: 双箭头
font-feature = calt, cv01, cv03, ss01, ss02, ss03
# 字体粗细(让字体更粗,类似 Tabby 600/700 配置)
font-thicken = true
# ========== 主题设置 ==========
theme = GitHub Dark Dimmed
# ========== 窗口尺寸 ==========
# 设置窗口初始大小(以字符为单位)
window-width = 175
window-height = 45
# 记住窗口位置和大小
window-save-state = always
# ========== 光标设置 ==========
# 光标样式:block(粗方块光标,类似 Tabby)
cursor-style = block
# 光标闪烁
cursor-style-blink = true
# 光标颜色(使用明亮的橙色,更醒目)
cursor-color = #ff9e64
# 光标下的文本颜色
cursor-text = #1a1b26
# ========== 窗口外观 ==========
# 窗口内边距
window-padding-x = 8
window-padding-y = 8
# 窗口装饰样式(macOS)- tabs 样式支持标签栏
macos-titlebar-style = tabs
# 保持窗口阴影
macos-window-shadow = true
# ========== 其他优化 ==========
# 背景略微透明(可选,1.0 为完全不透明)
background-opacity = 0.97
# 滚动缓冲区大小(单位:字节)
# 适合 Claude Code 等长对话应用
scrollback-limit = 200000000
# 在输入时隐藏鼠标
mouse-hide-while-typing = true
# ========== Shell Integration ==========
# 启用 shell 集成,但明确禁用 cursor 特性(避免覆盖我们的光标设置)
shell-integration = zsh
shell-integration-features = no-cursor,title
keybind = shift+enter=text:\x1b\r
keybind = ctrl+enter=text:\\\r
当前配置:
- 主题:GitHub Dark Dimmed(用户偏好,未更换为 Catppuccin)
- 字体:Maple Mono NF CN @ 17pt
- 启用连字特性:
calt, cv01, cv03, ss01, ss02, ss03 - 字体加粗:
font-thicken = true - 光标:block 样式,橙色闪烁
- 透明度:97%
- 滚动缓冲:200MB
Ghostty 内置主题:可通过 ghostty +list-themes 查看。
预览主题命令:
open -na Ghostty.app --args --theme="主题名"
2.2 Zsh 插件配置
已安装(通过 Homebrew):
brew install starship zsh-autosuggestions zsh-syntax-highlighting zsh-completions
配置文件:~/.zshrc
新增内容:
# ══════════════════════════════════════════════════════════════════════
# 2. 命令补全
# ══════════════════════════════════════════════════════════════════════
# Zsh 补全系统增强
if type brew &>/dev/null; then
FPATH="$(brew --prefix)/share/zsh-completions:$FPATH"
FPATH="$(brew --prefix)/share/zsh/site-functions:$FPATH"
fi
# 初始化补全系统(必须在设置 FPATH 之后、加载补全脚本之前)
autoload -Uz compinit
# 使用缓存加速,每天只重建一次
if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then
compinit
else
compinit -C
fi
# ══════════════════════════════════════════════════════════════════════
# 5. Zsh 插件
# ══════════════════════════════════════════════════════════════════════
# zsh-autosuggestions - 根据历史命令自动补全建议(灰色提示)
if [ -f "$(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh" ]; then
source "$(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
fi
# zsh-syntax-highlighting - 命令语法高亮
if [ -f "$(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]; then
source "$(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
fi
# ══════════════════════════════════════════════════════════════════════
# 6. 提示符主题 (Starship)
# ══════════════════════════════════════════════════════════════════════
if command -v starship &>/dev/null; then
eval "$(starship init zsh)"
fi
权限修复(解决 compinit insecure directories 警告):
chmod go-w /opt/homebrew/share
chmod -R go-w /opt/homebrew/share/zsh
2.3 Starship 配置
配置文件位置:~/.config/starship.toml
当前配置(极简风格):
# Starship 极简风格配置
format = """
$os\
$username\
$directory\
$git_branch\
$git_status\
$python\
$conda\
$time\
$line_break\
$character"""
command_timeout = 1000
[os]
disabled = false
format = "[$symbol]($style) "
style = "bold white"
[os.symbols]
Macos = "" # 注意:需用 Python 写入,见下方说明
[username]
disabled = false
show_always = true
format = "[$user]($style) "
style_user = "bold cyan"
[directory]
format = "[$path]($style)[$read_only]($read_only_style) "
style = "bold blue"
truncation_length = 3
[git_branch]
format = "[$symbol$branch]($style) "
symbol = " "
style = "bold purple"
[git_status]
format = "([$all_status$ahead_behind]($style) )"
style = "bold yellow"
conflicted = " " # 需用 Python 写入
ahead = "⇡${count}"
behind = "⇣${count}"
diverged = "⇕⇡${ahead_count}⇣${behind_count}"
untracked = " ${count} " # 需用 Python 写入
stashed = " ${count} " # 需用 Python 写入
modified = " ${count} " # 需用 Python 写入
staged = " ${count} " # 需用 Python 写入
renamed = " ${count} " # 需用 Python 写入
deleted = " ${count} " # 需用 Python 写入
[python]
format = "[$symbol($virtualenv )]($style)"
symbol = " "
style = "bold yellow"
[conda]
format = "[$symbol$environment]($style) "
symbol = " "
style = "bold green"
ignore_base = false
[time]
disabled = false
format = "[$time]($style) "
style = "dimmed white"
time_format = "%H:%M"
[character]
success_symbol = "[❯](bold green)"
error_symbol = "[❯](bold red)"
三、启动时间对比
| 状态 | 时间 | 说明 |
|---|---|---|
| 配置前 | ~130ms | 基础配置 |
| 配置后(无系统信息工具) | ~260ms | 插件 + Starship |
| + fastfetch | ~280ms | 推荐(仅增加 20ms) |
| + neofetch | ~460ms | 不推荐(增加 200ms) |
测试命令:
for i in 1 2 3; do time zsh -i -c exit; done
四、已解决问题
4.1 苹果图标不显示(已解决)
现象:Starship 的 [os] 模块或硬编码方式无法正常显示苹果图标。
根本原因:
Nerd Font 字符(如苹果图标 U+F179)属于 Unicode 私有使用区域(PUA),在以下场景会丢失:
- 编辑器保存时过滤 PUA 字符
- 复制粘贴时字符丢失
- Bash heredoc / echo 重定向时字符被丢弃
解决方案:使用 Python 写入 Nerd Font 字符
# 写入 os.symbols 的苹果图标
python3 -c "
with open('/Users/lostsheep/.config/starship.toml', 'r') as f:
content = f.read()
content = content.replace('Macos = \"\"', 'Macos = \"\uf179\"')
with open('/Users/lostsheep/.config/starship.toml', 'w') as f:
f.write(content)
"
验证方法:
# 检查字符是否正确写入(应显示 ef 85 b9)
grep "Macos" ~/.config/starship.toml | xxd
# 测试 os 模块输出
starship module os
4.2 Git Status 图标配置(已解决)
现象:git_status 模块使用文本符号(如 !, ?)显示,希望改为 Nerd Font 图标。
解决方案:使用 Python 写入 Nerd Font 图标
python3 -c "
with open('/Users/lostsheep/.config/starship.toml', 'r') as f:
content = f.read()
# git_status 图标替换
replacements = {
'modified = \"!\${count}\"': 'modified = \"\uf044 \${count} \"', # pencil
'untracked = \"?\${count}\"': 'untracked = \"\uf016 \${count} \"', # file-o
'staged = \"+\${count}\"': 'staged = \"\uf067 \${count} \"', # plus
'deleted = \"✘\${count}\"': 'deleted = \"\uf014 \${count} \"', # trash
'renamed = \"»\${count}\"': 'renamed = \"\uf061 \${count} \"', # arrow-right
'conflicted = \"=\"': 'conflicted = \"\uf071 \"', # warning
'stashed = \"\$\${count}\"': 'stashed = \"\uf187 \${count} \"', # archive
}
for old, new in replacements.items():
content = content.replace(old, new)
with open('/Users/lostsheep/.config/starship.toml', 'w') as f:
f.write(content)
"
图标对照表:
| 状态 | 图标 | Unicode | 名称 |
|---|---|---|---|
| modified | U+F044 | pencil | |
| untracked | U+F016 | file-o | |
| staged | U+F067 | plus | |
| deleted | U+F014 | trash | |
| renamed | U+F061 | arrow-right | |
| conflicted | U+F071 | warning | |
| stashed | U+F187 | archive |
五、可选工具
5.1 Fastfetch(推荐)
为什么选择 Fastfetch?
| 对比项 | Fastfetch | Neofetch |
|---|---|---|
| 执行速度 | 30-40ms | 200-300ms |
| 语言 | C(编译型) | Bash(解释型) |
| 启动影响 | +20ms(几乎无感知) | +200ms(明显卡顿) |
结论:Fastfetch 比 neofetch 快 6-10 倍,对终端启动速度影响极小。
安装
brew install fastfetch
使用
# 直接运行
fastfetch
# 测试性能
time fastfetch
配置自动启动
在 ~/.zshrc 末尾添加:
# ══════════════════════════════════════════════════════════════════════
# 7. 系统信息显示
# ══════════════════════════════════════════════════════════════════════
# fastfetch - 快速显示系统信息(~30ms)
if command -v fastfetch &>/dev/null; then
fastfetch
fi
配置位置:~/.zshrc:181-188(在 Starship 初始化之后)
显示效果
启动终端时自动显示:
- macOS ASCII Logo(彩色渐变)
- 系统版本、内核信息
- 硬件信息(CPU、GPU、内存)
- 显示器配置
- 终端、Shell 信息
- 颜色测试条
自定义配置(可选)
# 生成默认配置文件
fastfetch --gen-config
# 配置文件位置
~/.config/fastfetch/config.jsonc
简化显示示例(只显示核心信息):
在 .zshrc 中修改为:
fastfetch --logo small --structure Title:Separator:OS:Host:Kernel:Uptime:Shell:Terminal:CPU:Memory
性能验证
在 Apple M4 Mac mini 上的实测:
- fastfetch 单独执行:35ms
- 终端启动总时间:280ms(相比无 fastfetch 的 260ms 仅增加 20ms)
5.2 Neofetch(不推荐)
性能警告:Neofetch 使用 Bash 脚本实现,启动耗时 200-300ms,会明显拖慢终端启动速度。
推荐使用 Fastfetch 替代(快 6-10 倍,功能相同)。
Neofetch 是一个命令行系统信息工具,可以显示 ASCII 艺术图标和系统信息。
安装:
brew install neofetch
使用:
neofetch
配置苹果图标:
macOS 下 neofetch 默认显示苹果 ASCII 图标,无需额外配置。如需自定义,可编辑配置文件:
# 生成默认配置文件
mkdir -p ~/.config/neofetch
neofetch --print_config > ~/.config/neofetch/config.conf
# 编辑配置
vim ~/.config/neofetch/config.conf
常用配置选项(在 config.conf 中):
# 更换 ASCII 图标(可选:auto, ascii, wallpaper, 或指定图片路径)
image_source="auto"
# 指定使用某个发行版的 ASCII 图标
ascii_distro="macos"
# ASCII 图标颜色(使用 Nerd Font 调色板)
ascii_colors=(2 3 1 1 5 4)
# 隐藏某些信息行
print_info() {
info title
info underline
info "OS" distro
info "Host" model
info "Kernel" kernel
info "Uptime" uptime
info "Packages" packages
info "Shell" shell
info "Terminal" term
info "CPU" cpu
info "GPU" gpu
info "Memory" memory
info cols
}
终端启动时自动显示:
在 ~/.zshrc 末尾添加:
# Neofetch - 启动时显示系统信息
if command -v neofetch &>/dev/null; then
neofetch
fi
注意:
- 不推荐加入
.zshrc,会增加 200-300ms 启动时间 - 建议改用 Fastfetch(快 6-10 倍,功能相同)
- 如需使用,建议仅手动运行
neofetch查看系统信息
六、相关命令速查
Ghostty
# 列出所有主题
ghostty +list-themes
# 预览主题(新窗口)
open -na Ghostty.app --args --theme="主题名"
# 编辑配置
ghostty +edit-config
Starship
# 查看版本
starship --version
# 测试单个模块
starship module os
# 预设配置
starship preset catppuccin-powerline -o ~/.config/starship.toml
Zsh 启动时间
# 测试启动时间
for i in 1 2 3; do time zsh -i -c exit; done
Fastfetch
# 查看版本
fastfetch --version
# 运行并测试性能
time fastfetch
# 生成配置文件
fastfetch --gen-config
# 自定义显示内容
fastfetch --logo small --structure Title:OS:Host:Kernel:CPU:Memory
七、配置文件位置汇总
| 文件 | 路径 |
|---|---|
| Ghostty 配置 | ~/Library/Application Support/com.mitchellh.ghostty/config |
| Zsh 环境变量 | ~/.zshenv (如果你的配置没有使用则不添加) |
| Zsh 私密配置 | ~/.zshenv.local (如果你的配置没有使用则不添加) |
| Zsh 交互式配置 | ~/.zshrc |
| Starship 配置 | ~/.config/starship.toml |
| Fastfetch 配置 | ~/.config/fastfetch/config.jsonc |
| Neofetch 配置 | ~/.config/neofetch/config.conf |
八、参考链接
- Ghostty 官网
- Starship 官方文档
- Fastfetch GitHub
- Neofetch GitHub(已停止维护)
- Maple Mono 字体
- 原帖链接
最后,希望各位佬友都有自己的精致小玩具
网友解答:--【壹】--:
佬 知道咋配置标签页 感觉标签页切换不太明显
image3794×282 75.2 KB
--【贰】--:
怪好看的……但…我觉得我用putty就够了
--【叁】--:
谢谢大佬分享配置!!!
--【肆】--:
哈哈,就是这个字体
--【伍】--:
太强了,大佬!
--【陆】--:
image3490×114 44.4 KB
还能看到啊
--【柒】--:
ghostty可不是小玩具。是基础设施。
--【捌】--:
不错不错! 还是折腾有意思啊!
我折腾 nushell 还没搞清楚一点~ 佬太强了!
--【玖】--:
分屏下的标题怎么解决呢?且之前试了一下,就碰到这个问题,就没再用了。因为到四分屏之后,完全看不到这个终端开的内容是什么了。
--【拾】--:
tql大佬
--【拾壹】--:
tql佬
--【拾贰】--:
牛啊牛啊,
--【拾叁】--:
暴露了我是老登的事实……
--【拾肆】--:
putty 是啥,还没用过呢
--【拾伍】--: Jerry Hou:
我觉得我用putty就够
重量级选手
--【拾陆】--:
应该是看你主题的,我的主题是 GitHub Dark Dimmed 这个,在 macOS26 上的风格是这样的:
image3802×178 29.2 KB
--【拾柒】--:
太强了佬 前几天我还刚摸索问了一个帖子 结果你这边发了更完整的教程了 相遇恨晚
分割线 哈哈没看到开头 刚发现
另外字体用的 Maple Mono Normal NF CN 这个感觉更好看一点
brew install --cask font-maple-mono-normal-nf-cn
--【拾捌】--:
哈哈,有道理
--【拾玖】--:
好看,谢谢佬友分享

