ByteNoteByteNote

字节笔记本

2026年8月15日

Ghostty macOS 开发终端配置指南

API中转
¥120

这篇文章分享一份偏「干净、Gruvbox、适合 tmux / 编程」的 Ghostty 终端配置,覆盖配置文件位置、字体、主题、窗口、半透明效果和 Shell 集成等关键项,适合在 macOS 上把 Ghostty 当主力开发终端的用户。

配置文件位置

Ghostty 现在推荐的配置文件是 ~/.config/ghostty/config.ghostty。从 Ghostty 1.2.3 起主文件名改成了 config.ghostty,旧的 config 仍然兼容。macOS 也支持 ~/Library/Application Support/com.mitchellh.ghostty/,不过放 ~/.config/ghostty/ 更适合管理 dotfiles。

先执行:

bash
mkdir -p ~/.config/ghostty
nano ~/.config/ghostty/config.ghostty

然后直接放这一版:

ini
# =========================================================
# Ghostty
# macOS / Development / tmux
# =========================================================

# ---------------------------------------------------------
# Font
# ---------------------------------------------------------

font-family = JetBrainsMono Nerd Font
font-size = 15

# 如果上面的字体不存在,查看 Ghostty 能识别到的字体:
# ghostty +list-fonts


# ---------------------------------------------------------
# Theme
# ---------------------------------------------------------

theme = Gruvbox Dark Hard


# ---------------------------------------------------------
# Window
# ---------------------------------------------------------

window-padding-x = 12
window-padding-y = 10
window-padding-balance = true

# macOS 原生圆角 + 融合标题栏
macos-titlebar-style = transparent

# Option 作为 Alt,tmux / shell / vim 更方便
macos-option-as-alt = true


# ---------------------------------------------------------
# Background
# ---------------------------------------------------------

background-opacity = 0.94
background-blur = 20


# ---------------------------------------------------------
# Cursor
# ---------------------------------------------------------

cursor-style = block
cursor-style-blink = false


# ---------------------------------------------------------
# Mouse
# ---------------------------------------------------------

mouse-hide-while-typing = true


# ---------------------------------------------------------
# Clipboard
# ---------------------------------------------------------

# 选中文字立即进入系统剪贴板
copy-on-select = clipboard

# 保留危险多行粘贴保护
clipboard-paste-protection = true


# ---------------------------------------------------------
# Scrollback
# ---------------------------------------------------------

# 128 MB
scrollback-limit = 134217728


# ---------------------------------------------------------
# Shell
# ---------------------------------------------------------

shell-integration = zsh

# sudo 时正确处理 Ghostty terminfo
# SSH 到服务器时提高兼容性
shell-integration-features = sudo,ssh-env


# ---------------------------------------------------------
# Closing
# ---------------------------------------------------------

# 不因为 shell 里还有进程反复弹确认
confirm-close-surface = false


# ---------------------------------------------------------
# Splits
# ---------------------------------------------------------

# 不把非活动 split 弄得太暗
unfocused-split-opacity = 0.92

这些配置项都是目前 Ghostty 官方 Reference 中仍然存在的配置。其中字体可以用 ghostty +list-fonts 查准确名称,而且 font-family 支持重复声明来做 fallback。

Gruvbox 主题

ini
theme = Gruvbox Dark Hard

Ghostty 内置了大量主题,可以运行 ghostty +list-themes 查看完整列表,比如只看 Gruvbox:

bash
ghostty +list-themes | grep -i gruvbox

半透明不要开太狠

建议:

ini
background-opacity = 0.94
background-blur = 20

Ghostty 官方现在的 background-blur 已经直接接受整数值,20 也是官方认为比较合理的默认模糊强度。

如果已经是 macOS 26+,还可以试 Ghostty 新的系统玻璃效果:

ini
background-opacity = 0.94
background-blur = macos-glass-regular

或者更透明:

ini
background-blur = macos-glass-clear

这是 Ghostty 针对 macOS 26+ 提供的原生 Glass 模式。更推荐 macos-glass-regular,不要 clear,写代码久了背景干扰会比较明显。

macOS 标题栏

ini
macos-titlebar-style = transparent

Ghostty 目前支持:

text
native
transparent
tabs
hidden

transparent 会保留 macOS 原生窗口体验,同时让标题栏和终端背景融合。如果特别喜欢 Ghostty 自己管理 Tab,也可以改用 tabs

tmux / SSH

建议保留:

ini
shell-integration = zsh
shell-integration-features = sudo,ssh-env

Ghostty 的 Shell Integration 可以让新 Tab/Split 继承工作目录,也能处理 prompt 标记;sudo 用于处理 terminfo,ssh-env 则会在 SSH 场景提高终端环境兼容性。这对「Ghostty → zsh → tmux → SSH」这种开发方式很合适。

修改后不用退出 Ghostty

⌘ + Shift + , 就可以重新加载配置,这是 macOS 当前默认的 Reload Config 快捷键。

进一步:Starship + tmux

这套比单独折腾 Ghostty 外观更值得。Ghostty 只负责「窗口 + 渲染」,Starship 和 tmux 分别负责 Prompt 和长期工作区,最终形态大概是:

text
Ghostty
├── Gruvbox Dark Hard
├── JetBrainsMono Nerd Font
├── 半透明 / macOS Glass
├── Starship
├── zsh
└── tmux
    ├── session 自动恢复
    ├── 鼠标
    ├── vim 风格 pane 切换
    └── Gruvbox 状态栏

参考链接

分享: