1643 字
8 分钟
从 Warp 迁移到 Ghostty

随着 Claude Code、Cursor Agent 等终端 AI 工具的兴起,终端不再只是敲命令的地方,而是主力开发环境。一个高效、轻量、可控的终端模拟器变得前所未有的重要。

ghostty-org
/
ghostty
Waiting for api.github.com...
00K
0K
0K
Waiting...

为什么离开 Warp#

Warp 是一款基于 Rust 开发的现代化终端,主打 AI 辅助、块编辑、命令搜索等创新功能。我使用了大约一年,确实带来了不少便利,但随着使用深入,一些问题逐渐暴露:

  • 资源占用高:GPU 渲染 + 丰富功能 = 明显的内存和 CPU 开销

Warp 内存占用

  • 启动慢:冷启动 2-3 秒,打断工作心流
  • 强制登录:必须注册账号才能使用,终端工具为什么需要账号?
  • 内置 AI 鸡肋:实际工作中更多依赖 Claude Code,内置 AI 几乎没用过
  • 闭源:无法自定义或贡献代码

为什么选择 Ghostty#

Ghostty 由 HashiCorp 联合创始人 Mitchell Hashimoto 开发,使用 Zig 语言编写。它的设计理念恰好解决了我对 Warp 的所有不满:

  • 极速启动:GPU 加速渲染,启动几乎瞬间完成
  • 资源占用低:内存仅 Warp 的 1/3

Ghostty 内存占用

  • 完全开源:MIT 协议,社区活跃
  • 无需账号:开箱即用
  • 原生体验:遵循 macOS 设计规范
  • 配置简洁:单文件配置,语法直观

安装#

Terminal window
brew install --cask ghostty

也可以从 官网 直接下载。

配置#

Ghostty 使用单文件配置 ~/.config/ghostty/config

初始化配置
mkdir -p ~/.config/ghostty && touch ~/.config/ghostty/config
# 安装字体(配置中使用)
brew install --cask font-maple-mono-nf-cn

我的完整配置:

~/.config/ghostty/config
# ========== 字体设置 ==========
# 主字体:Maple Mono NF CN
font-family = Maple Mono NF CN
font-size = 14
# 行高设置(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 = 125
window-height = 35
# 记住窗口位置和大小
window-save-state = always
# ========== 光标设置 ==========
# 光标样式:block(粗方块光标,类似 Tabby)
cursor-style = bar
# 光标闪烁
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

主题#

Ghostty 内置大量主题:

查看可用主题
ghostty +list-themes
常用主题
theme = tokyonight
theme = catppuccin-mocha
theme = dracula
theme = nord
theme = GitHub Dark Dimmed # 我在用的

自定义主题可放在 ~/.config/ghostty/themes/ 目录下。

迁移调整#

Warp 开箱即用,Ghostty 需要手动配置。但这也意味着更高的可控性。

命令行增强#

Warp 内置了历史补全、语法高亮。在 Ghostty 中通过 zsh 插件实现:

安装 zsh 插件
brew install zsh-autosuggestions zsh-syntax-highlighting zsh-completions

~/.zshrc 中添加以下配置:

~/.zshrc
# -----------------------
# Homebrew Zsh completions (must be BEFORE oh-my-zsh / compinit)
# -----------------------
if type brew &>/dev/null; then
export BREW_PREFIX="$(brew --prefix)"
FPATH="$BREW_PREFIX/share/zsh-completions:$FPATH"
FPATH="$BREW_PREFIX/share/zsh/site-functions:$FPATH"
fi
# -----------------------
# Zsh plugins (Homebrew)
# -----------------------
# zsh-autosuggestions - 根据历史命令自动补全建议(灰色提示)
if [[ -n "$BREW_PREFIX" && -f "$BREW_PREFIX/share/zsh-autosuggestions/zsh-autosuggestions.zsh" ]]; then
source "$BREW_PREFIX/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
fi
# zsh-syntax-highlighting - 命令语法高亮(必须放在最后)
if [[ -n "$BREW_PREFIX" && -f "$BREW_PREFIX/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then
source "$BREW_PREFIX/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
fi
NOTE

如果使用 Oh My Zsh,不要zsh-autosuggestionszsh-syntax-highlighting 放入 plugins=() 中,否则会与 Homebrew 安装的版本重复加载。

这三个插件分别提供:

  • zsh-autosuggestions:历史命令补全(按 确认)
  • zsh-syntax-highlighting:语法高亮,错误命令显示红色
  • zsh-completions:增强的 Tab 补全

提示符主题 - Spaceship#

Warp 有漂亮的内置提示符,Ghostty 中可以用 Spaceship 实现类似效果。

1. 安装 Oh My Zsh(前置条件)#

Spaceship 依赖 Oh My Zsh 框架,需先安装:

安装 Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
WARNING

安装脚本会将原有 ~/.zshrc 备份为 ~/.zshrc.pre-oh-my-zsh,并生成新的配置文件。安装完成后需手动将原配置迁移到新文件中。

2. 安装 Spaceship 主题#

克隆 Spaceship 到 Oh My Zsh 主题目录
git clone https://github.com/spaceship-prompt/spaceship-prompt.git \
"${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/spaceship-prompt" --depth=1
# 创建符号链接
ln -sf \
"${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/spaceship-prompt/spaceship.zsh-theme" \
"${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/spaceship.zsh-theme"

3. 启用主题#

Oh My Zsh 安装后会自动生成 ~/.zshrc,找到 ZSH_THEME 那一行,修改为:

~/.zshrc
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="spaceship"
source "$ZSH/oh-my-zsh.sh"

Spaceship 会显示 Git 分支、Node 版本、执行时间等上下文信息,非常适合开发者使用。

历史命令搜索 - Atuin#

Warp 的历史命令弹出列表很方便,Atuin 是更强大的替代品:

安装 Atuin
brew install atuin
# 初始化(添加到 ~/.zshrc)
eval "$(atuin init zsh)"
# 导入现有的 shell 历史记录
atuin import auto

Atuin 配置文件位于 ~/.config/atuin/config.toml,我的配置如下:

~/.config/atuin/config.toml
# ↑ 键触发的过滤范围:全局(所有目录/会话/主机)
filter_mode_shell_up_key_binding = "global"
# ↑ 键触发的搜索模式:前缀匹配(适合 ssh、git 等命令)
search_mode_shell_up_key_binding = "prefix"
# 紧凑样式
style = "compact"
# 内联高度(行数)
inline_height = 14
# 关闭预览(命令太长时的预览)
show_preview = false
# 关闭帮助行和标签栏,界面更简洁
show_help = false
show_tabs = false
# 回车直接执行命令(按 Tab 可编辑)
enter_accept = true
[sync]
# 启用 sync v2
records = true
TIP

配置完成后,按 键即可弹出历史命令列表,输入关键字即可快速筛选。

Atuin 的优势:

  • 全文搜索Ctrl+R 弹出交互式搜索
  • 跨设备同步:可选云端同步
  • 统计分析:命令使用频率统计
  • 上下文感知:按目录、会话筛选

Atuin 界面示意

对比#

对比项WarpGhostty
启动速度2-3 秒< 0.5 秒
内存占用~600 MB~100 MB
开源
需要账号
内置 AI
块编辑
自定义程度

快捷键#

操作快捷键
水平分屏Cmd+D
垂直分屏Cmd+Shift+D
切换分屏Cmd+[ / Cmd+]
关闭分屏Cmd+W
打开配置Cmd+Shift+,
TIP

修改配置文件后 Ghostty 会自动重载,无需重启。

总结#

Warp 像一辆带自动驾驶的车;Ghostty 更像一台手动挡。

更累,但我终于知道每个动作是谁做的。

从 Warp 迁移到 Ghostty
https://www.mihouo.com/posts/tool-share/from-warp-to-ghostty/
作者
发布于
2025-12-26
许可协议
CC BY-NC-SA 4.0