Ghostty 的核心优势:
确认系统已安装 Homebrew:
which brew如未安装,执行:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"通过 Homebrew Cask 安装:
brew install --cask ghostty安装过程会自动完成以下操作:
检查应用是否正确安装:
ls -la /Applications/Ghostty.app查看版本信息:
/Applications/Ghostty.app/Contents/MacOS/ghostty --version输出示例:
Ghostty 1.2.3
Version
- version: 1.2.3
- channel: stable
Build Config
- Zig version : 0.14.1
- build mode : builtin.OptimizeMode.ReleaseFast
- app runtime : apprt.Runtime.none
- font engine : font.main.Backend.coretext
- renderer : renderer.generic.Renderer(renderer.Metal)
- libxev : kqueueGhostty 使用纯文本配置文件,位于:
~/.config/ghostty/config创建配置目录:
mkdir -p ~/.config/ghostty创建配置文件 ~/.config/ghostty/config:
# Ghostty 配置文件
# 完整文档: https://ghostty.org/docs
# ============ 字体设置 ============
# 字体系列(推荐使用等宽编程字体)
# 原来使用 JetBrains Mono,这里改为更接近 Claude 的 SF Mono
font-family = "SF Mono"
# 备选字体(如果上面的字体不可用)
# font-family = "Menlo"
# font-family = "Monaco"
# 字体大小
# Claude 风格略大一点,阅读更舒适
font-size = 13
# 启用 / 关闭连字(ligatures)
# Claude 风格更偏阅读,不使用编程连字
# 这是“字间距看起来变小”的关键
font-feature = -calt
font-feature = -liga
# ============ 主题和颜色 ============
# 背景透明度 (0.0-1.0, 1.0 为完全不透明)
background-opacity = 0.97
# 窗口模糊效果
background-blur = 24
# 暗黑主题:深色背景与浅色前景
# 选项 1: VS Code Dark+ 风格
#background = #1e1e1e
#foreground = #d4d4d4
# 选项 2: macOS 终端暗黑风格
background = #1d1f21
foreground = #c5c8c6
# 选项 3: Dracula 风格 - 蓝紫
#background = #282a36
#foreground = #f8f8f2
# 可选:添加 ANSI 颜色以获得更好的暗黑主题效果
# 黑色
palette = 0=#1e1e1e
palette = 8=#5a5a5a
# 红色
palette = 1=#f38ba8
palette = 9=#f38ba8
# 绿色
palette = 2=#a6e3a1
palette = 10=#a6e3a1
# 黄色
palette = 3=#f9e2af
palette = 11=#f9e2af
# 蓝色
palette = 4=#89b4fa
palette = 12=#89b4fa
# 紫色/品红
palette = 5=#f5c2e7
palette = 13=#f5c2e7
# 青色
palette = 6=#94e2d5
palette = 14=#94e2d5
# 白色
palette = 7=#d4d4d4
palette = 15=#ffffff
# ============ 窗口设置 ============
# 窗口装饰(可选: true, false, client-side)
window-decoration = true
# 窗口内边距
# Claude UI 有明显“空气感”
window-padding-x = 16
window-padding-y = 16
# 初始窗口大小(列x行)
window-width = 80
window-height = 100
# ============ 光标设置 ============
# 光标样式(可选: block, bar, underline)
# Claude 风格是细竖线
cursor-style = bar
# 光标闪烁
# Claude 中基本不闪
cursor-style-blink = false
# ============ 滚动设置 ============
# 滚动历史行数
scrollback-limit = 10000
# 鼠标滚轮滚动速率(默认为 1.0,增加这个值可以加快滚动)
mouse-scroll-multiplier = 6.6
# 触控板滚动速率(如果你使用触控板)
# 默认值通常足够,但可以调整
# touch-scroll-multiplier = 1.0
# ============ Shell 集成 ============
# 启用 shell 集成功能
shell-integration = detect
# 自动检测并集成当前 shell
shell-integration-features = cursor,sudo,title
# ============ 快捷键设置 ============
# 新建标签页
keybind = ctrl+t=new_tab
# 关闭标签页
keybind = ctrl+w=close_surface
# 切换标签页
keybind = ctrl+shift+[=previous_tab
keybind = ctrl+shift+]=next_tab
# 分屏
keybind = ctrl+d=new_split:right
keybind = ctrl+shift+d=new_split:down
# 切换分屏
keybind = ctrl+[=goto_split:previous
keybind = ctrl+]=goto_split:next
# 清屏
keybind = ctrl+k=clear_screen
# 复制粘贴
keybind = ctrl+c=copy_to_clipboard
keybind = ctrl+v=paste_from_clipboard
# 查找
# ⚠️ 你原来是 toggle_quick_terminal,这里保持不动
keybind = ctrl+f=toggle_quick_terminal
# 放大缩小字体
keybind = ctrl+plus=increase_font_size:1
keybind = ctrl+minus=decrease_font_size:1
keybind = ctrl+0=reset_font_size
# ============ 其他设置 ============
# 确认退出(当有多个标签页时)
confirm-close-surface = true
# 鼠标隐藏延迟(毫秒)
mouse-hide-while-typing = true
# 点击链接时使用的修饰键(可选: shift, ctrl, alt, super)
# ⚠️ 你这里原本就是注释状态,保持原样
# 按住 cmd 键点击链接打开
click-repeat-interval = 300
# 复制时自动去除尾随空格
copy-on-select = false
推荐使用等宽编程字体。安装 JetBrains Mono:
brew install --cask font-jetbrains-mono其他可选字体:
brew install --cask font-fira-codebrew install --cask font-hackbrew install --cask font-source-code-promacOS 系统自带字体可选:
在配置文件中添加自定义快捷键:
# 标签页
keybind = cmd+t=new_tab
keybind = cmd+w=close_surface
keybind = cmd+shift+[=previous_tab
keybind = cmd+shift+]=next_tab
# 分屏
keybind = cmd+d=new_split:right
keybind = cmd+shift+d=new_split:down
keybind = cmd+[=goto_split:previous
keybind = cmd+]=goto_split:next
# 工具
keybind = cmd+k=clear_screen
keybind = cmd+f=toggle_quick_terminal
# 字体大小
keybind = cmd+plus=increase_font_size:1
keybind = cmd+minus=decrease_font_size:1
keybind = cmd+0=reset_font_size
# 剪贴板
keybind = cmd+c=copy_to_clipboard
keybind = cmd+v=paste_from_clipboard启动方式:
标签页管理:
分屏功能:
文本操作:
视图调整:
Ghostty 支持自动检测并集成 shell 功能。启用后可获得:
配置项:
shell-integration = detect
shell-integration-features = cursor,sudo,titleGPU 渲染:
Ghostty 默认使用 Metal API 进行 GPU 加速渲染,无需额外配置。
滚动缓冲区调整:
scrollback-limit = 10000 # 根据内存情况调整禁用不必要的特性:
cursor-style-blink = false # 禁用光标闪烁可提升性能可以为不同场景创建不同配置:
# 开发环境配置
~/.config/ghostty/config.dev
# 生产环境配置
~/.config/ghostty/config.prod启动时指定配置:
/Applications/Ghostty.app/Contents/MacOS/ghostty --config ~/.config/ghostty/config.dev在配置文件中指定启动 shell:
command = /bin/zsh或启动特定命令:
command = tmux attach -t dev || tmux new -s dev配合 yabai 等窗口管理器使用:
# 禁用原生窗口装饰,使用平铺窗口管理器
window-decoration = false
# 移除内边距以最大化空间利用
window-padding-x = 0
window-padding-y = 0| 特性 | Ghostty | iTerm2 | Alacritty | Terminal.app |
|---|---|---|---|---|
| 启动速度 | 极快 | 中等 | 极快 | 快 |
| 渲染性能 | GPU 加速 | CPU/GPU | GPU 加速 | CPU |
| 内存占用 | 低 | 高 | 低 | 中 |
| macOS 集成 | 原生 | 良好 | 一般 | 原生 |
| 配置方式 | 文本文件 | GUI+文本 | 文本文件 | GUI |
| 分屏支持 | 内置 | 内置 | 需配合 tmux | 内置 |
| 扩展性 | 有限 | 丰富 | 有限 | 有限 |
Homebrew 安装的是 GUI 应用,需要使用完整路径或创建别名:
# 添加到 ~/.zshrc 或 ~/.bashrc
alias ghostty="/Applications/Ghostty.app/Contents/MacOS/ghostty"配置文件修改后需要重启 Ghostty。确认配置文件路径正确:
cat ~/.config/ghostty/config检查字体是否已安装:
fc-list | grep "JetBrains Mono"或使用系统自带字体:
font-family = "Menlo"确认配置项正确:
background-opacity = 0.95 # 范围 0.0-1.0某些情况下需要禁用窗口装饰:
window-decoration = falseGhostty 1.2.3 版本中,部分配置项已不再支持或默认启用,如遇到配置错误,需要移除以下配置:
不支持的配置项:
theme = dark - 该版本暂不支持主题配置,使用系统主题gpu-renderer = metal - GPU 渲染默认启用,无需配置unicode-input = true - Unicode 输入默认启用emoji-presentation = emoji - Emoji 支持默认启用如果启动时提示配置错误,检查配置文件并移除上述配置项,然后点击 "Reload Configuration" 重新加载。
经过一周的实际使用,Ghostty 在以下场景表现出色:
优势:
npm install、docker logs)不足:
Ghostty 是一个性能优异、配置简洁的现代终端模拟器,特别适合:
对于需要丰富插件和高度定制化的用户,iTerm2 可能仍是更好的选择。但如果你的需求是一个快速、稳定、配置简单的终端,Ghostty 值得尝试。
man ghostty 或 man 5 ghostty
加载评论中...