从零搭建一套快速、现代、好看的终端工作流: Ghostty 终端 · Claude Code · Oh My Zsh · kali-zsh-theme · yazi
简体中文 · English
- 这份指南能给你什么
- 先决条件
- 1. 安装 Ghostty
- 2. 配置 Ghostty
- 3. 安装 Nerd Font
- 4. 配置 Zsh + Oh My Zsh
- 5. 应用 kali-zsh-theme 主题
- 6. 加上两个必备插件
- 7. 安装 yazi 文件管理器
- 8. 安装并接入 Claude Code
- 9. 一份完整的配置示例
- 10. 常见问题排查
- 致谢与许可
读完并照做后,你会得到:
- Ghostty —— 由 Mitchell Hashimoto(HashiCorp、Vagrant 作者)开发的 GPU 加速终端,启动快、原生分屏、零配置开箱可用,还能高度定制。
- Claude Code —— 在终端里直接对话式编程的 AI 助手,配合 Ghostty 的 shell 集成体验丝滑。
- Oh My Zsh —— zsh 配置框架,插件 / 主题生态成熟。
- kali-zsh-theme —— Kali Linux 同款双行提示符,清爽又能一眼看清路径、权限、退出码。
- yazi —— Rust 写的极速终端文件管理器,按
y进入、退出自动cd到你停留的目录。
最终效果是一套快、稳、好看、AI 原生的终端工作流。
- macOS 或 Linux(Windows 用户可在 WSL2 里照做 zsh 部分;Ghostty 暂不支持原生 Windows)
- 已安装 Homebrew(macOS / Linux 通用的包管理器):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install --cask ghostty大多数发行版可通过官方包或社区源安装,详见官网下载页:https://ghostty.org/download
ghostty --version看到版本号(如 Ghostty 1.3.1)即安装成功。打开 Ghostty,你已经拥有一个开箱即用的高性能终端了。
Ghostty 的配置是一个纯文本文件,无需重启即可热重载。
~/.config/ghostty/config
文件不存在就手动创建:
mkdir -p ~/.config/ghostty
touch ~/.config/ghostty/config每行一个 键 = 值,# 开头是注释。例如:
font-family = "JetBrainsMono Nerd Font"
font-size = 14
theme = "Catppuccin Mocha"
background-opacity = 0.95
background-blur = true| 配置项 | 作用 | 示例 |
|---|---|---|
font-family |
字体(建议 Nerd Font) | "JetBrainsMono Nerd Font" |
font-size |
字号 | 14 |
theme |
配色主题 | "Catppuccin Mocha" |
background-opacity |
背景透明度 0–1 | 0.95 |
background-blur |
背景毛玻璃模糊 | true |
window-padding-x/y |
窗口内边距 | 12 |
cursor-style |
光标样式 | bar / block |
copy-on-select |
选中即复制 | true |
macos-option-as-alt |
把 Option 当 Alt 键 | true |
keybind |
自定义快捷键 | 见下文 |
ghostty +list-themes # 463+ 个内置主题,方向键预览
ghostty +list-fonts # 列出系统可用字体
ghostty +show-config --default --docs # 全部配置项及说明改完配置文件后,在 Ghostty 窗口里按 Cmd+Shift+, 即可热重载(macOS);也可直接重启。
💡 本仓库
config/ghostty提供了一份为本指南优化好的完整配置,可直接拷贝使用。
kali-zsh-theme 用到框线字符 ┌ └ ─ 和 ㉿,各种插件/工具也常用图标字形。装一个 Nerd Font 一劳永逸:
brew install --cask font-jetbrains-mono-nerd-font
# 或:font-hack-nerd-font / font-fira-code-nerd-font / font-meslo-lg-nerd-font装好后在 Ghostty 配置里指定:
font-family = "JetBrainsMono Nerd Font"macOS 自带 zsh。安装 Oh My Zsh:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"它会自动备份你原来的 ~/.zshrc 并生成新的。核心两行:
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell" # 待会儿改成 kali
plugins=(git)
source "$ZSH/oh-my-zsh.sh"kali-zsh-theme 把 Kali Linux 标志性的双行提示符做成了 Oh My Zsh 主题:
┌──(user㉿host)-[~/path]
└─$
安装:
curl -fsSL https://raw.githubusercontent.com/casperkwok/kali-zsh-theme/main/kali.zsh-theme \
-o ~/.oh-my-zsh/custom/themes/kali.zsh-theme启用 —— 编辑 ~/.zshrc:
ZSH_THEME="kali"它的特性:root 自动变红、路径过深自动折叠、识别 Python 虚拟环境、命令失败显示退出码。详见该仓库 README。
Kali 终端体验的灵魂:语法高亮(命令对错实时变色)+ 自动补全建议(根据历史灰字提示)。
brew install zsh-syntax-highlighting zsh-autosuggestions在 ~/.zshrc 末尾加上(注意 syntax-highlighting 必须放最后):
source "$(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
source "$(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
zsh-autosuggestions也可以作为 Oh My Zsh 插件加进plugins=(...),二选一即可。
执行 source ~/.zshrc 生效。
yazi 是 Rust 写的极速终端文件管理器,支持图片预览、模糊查找、批量操作。
brew install yazi
# 推荐一并装上预览/查找依赖:
brew install ffmpeg sevenzip jq poppler fd ripgrep fzf zoxide imagemagick直接运行 yazi 即可使用。但更实用的是下面这个 y 函数:进入文件管理器,退出时自动把 shell 切到你最后停留的目录。加到 ~/.zshrc:
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
IFS= read -r -d '' cwd < "$tmp"
[ -n "$cwd" ] && [ "$cwd" != "$PWD" ] && builtin cd -- "$cwd"
rm -f -- "$tmp"
}之后输入 y,浏览到任意目录按 q 退出,shell 就停在那个目录了 —— 比反复 cd 高效得多。
Claude Code 是 Anthropic 官方的终端 AI 编程助手。
npm install -g @anthropic-ai/claude-code(需要 Node.js;没有的话 brew install node。)
在任意项目目录下:
claude首次运行按提示登录账号即可。
在 Claude Code 里写多行内容时,你会希望 Shift+Enter 是换行,Enter 才是提交。运行 Claude Code 内置命令一键配置:
/terminal-setup
它会自动为 Ghostty 写好对应键位。若没生效,可在 Ghostty 配置里手动加:
keybind = shift+enter=text:\n- Shell 集成(
shell-integration = detect)让 Claude Code 能准确感知当前工作目录、命令边界。 - 原生分屏(
Cmd+D)—— 一边跑 Claude Code,一边开个分屏看日志 / 跑测试,不必依赖 tmux。 - GPU 加速渲染 —— Claude Code 长输出、流式刷新时依然顺滑不卡。
本仓库提供可直接取用的示例文件:
config/ghostty—— Ghostty 完整配置(字体 / 主题 / 透明 / 分屏键位 / Claude Code 适配)config/zshrc-snippet.zsh——.zshrc关键片段(Oh My Zsh + kali 主题 + 插件 + yaziy函数)
一键铺设 Ghostty 配置:
mkdir -p ~/.config/ghostty
curl -fsSL https://raw.githubusercontent.com/casperkwok/ghostty-claude-code-guide/main/config/ghostty \
-o ~/.config/ghostty/config然后把 config/zshrc-snippet.zsh 里需要的部分合并进自己的 ~/.zshrc,source ~/.zshrc 即可。
提示符里的 ㉿ 或框线变成方块 / 乱码
字体没用 Nerd Font。回到 第 3 步 安装并在 Ghostty 配置 font-family 指定它。
改了 Ghostty 配置没反应
按 Cmd+Shift+, 重载,或重启 Ghostty。用 ghostty +show-config 查看当前实际生效的配置,确认没有拼写错误的键名(Ghostty 会忽略无法识别的项)。
zsh-syntax-highlighting 不高亮
确认它的 source 行放在 ~/.zshrc 的最后,在所有其它插件之后。
Claude Code 里 Shift+Enter 还是直接提交
先运行 /terminal-setup;无效再在 Ghostty 配置手动加 keybind = shift+enter=text:\n 并重载。
macOS 里 Alt/Option 快捷键不工作
在 Ghostty 配置加 macos-option-as-alt = true。
yazi 的 `y` 退出后没有切换目录
确认你用的是 y 函数而不是直接 yazi,且函数已 source(开新终端或 source ~/.zshrc)。
- Ghostty by Mitchell Hashimoto
- Claude Code by Anthropic
- Oh My Zsh
- yazi
- kali-zsh-theme
本指南以 MIT 许可发布。各上游项目遵循各自许可。