Ghostty 终端使用技巧

为什么选它

Ghostty 是 Mitchell Hashimoto 用 Zig 写的 GPU 加速终端模拟器。吸引我的点:单文件纯文本配置、内置分屏和 Quake 下拉终端、跟随系统自动切亮暗主题。不用折腾插件。


配置在哪

macOS 下配置文件路径:

1
~/Library/Application Support/com.mitchellh.ghostty/config

在终端里按 Cmd+, 直接打开。改完 Cmd+Shift+, 热重载,无需重启。


配置要点

字体 — JetBrainsMonoNerdFont,高分屏开启 font-thicken 避免字体过细:

1
2
3
4
font-family = JetBrainsMonoNerdFont
font-size = 14
font-thicken = true
adjust-cell-height = 2

主题 — 跟随系统自动切换 Catppuccin 亮/暗:

1
2
theme = light:Catppuccin Latte,dark:Catppuccin Mocha
window-theme = auto

可选主题用 ghostty +list-themes 查看。

毛玻璃窗口

1
2
3
4
5
6
background-opacity = 0.9
background-blur-radius = 20
macos-titlebar-style = transparent
window-padding-x = 10
window-padding-y = 8
window-save-state = always

Quake 下拉终端 — 全局热键 `Ctrl+`` 呼出/收起,多屏时跟随鼠标所在屏幕:

1
2
3
4
5
quick-terminal-position = top
quick-terminal-screen = mouse
quick-terminal-autohide = true
quick-terminal-animation-duration = 0.15
keybind = global:ctrl+grave_accent=toggle_quick_terminal

分屏 — 不用 tmux,内置键位就够了:

1
2
3
4
5
6
7
8
keybind = cmd+d=new_split:right
keybind = cmd+shift+d=new_split:down
keybind = cmd+alt+left=goto_split:left
keybind = cmd+alt+right=goto_split:right
keybind = cmd+alt+up=goto_split:top
keybind = cmd+alt+down=goto_split:bottom
keybind = cmd+shift+e=equalize_splits # 平分分屏尺寸
keybind = cmd+shift+f=toggle_split_zoom # 当前分屏全屏/还原

安全 — 粘贴内容含换行+命令时弹确认,防供应链攻击:

1
2
clipboard-paste-protection = true
clipboard-paste-bracketed-safe = true

其他

1
2
3
4
5
6
shell-integration = detect        # 自动注入 shell 集成
scrollback-limit = 25000000 # 大缓冲区,避免编译日志被冲掉
cursor-style = bar # 竖线光标
cursor-style-blink = true
copy-on-select = clipboard # 选中即复制
mouse-hide-while-typing = true # 打字时隐藏鼠标

换电脑还原

把下面这份完整配置保存到 ~/Library/Application Support/com.mitchellh.ghostty/config,启动 Ghostty 后按 Cmd+Shift+, 即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# 一键写入(终端里直接粘贴执行)
cat > ~/Library/Application\ Support/com.mitchellh.ghostty/config << 'EOF'
# ===========================
# === 字体 ===
# ===========================
font-family = JetBrainsMonoNerdFont
font-size = 14
font-thicken = true
adjust-cell-height = 2

# ===========================
# === 主题 (跟随系统明暗自动切换) ===
# ===========================
theme = light:Catppuccin Latte,dark:Catppuccin Mocha

# ===========================
# === 窗口 ===
# ===========================
background-opacity = 0.9
background-blur-radius = 20
macos-titlebar-style = transparent
window-padding-x = 10
window-padding-y = 8
window-save-state = always
window-theme = auto

# ===========================
# === 光标 ===
# ===========================
cursor-style = bar
cursor-style-blink = true
cursor-opacity = 0.8

# ===========================
# === 鼠标 ===
# ===========================
mouse-hide-while-typing = true
copy-on-select = clipboard

# ===========================
# === 下拉终端 (Quake 风格, Ctrl+`) ===
# ===========================
quick-terminal-position = top
quick-terminal-screen = mouse
quick-terminal-autohide = true
quick-terminal-animation-duration = 0.15

# ===========================
# === 安全 ===
# ===========================
clipboard-paste-protection = true
clipboard-paste-bracketed-safe = true

# ===========================
# === Shell 集成 ===
# ===========================
shell-integration = detect

# ===========================
# === 快捷键 ===
# ===========================
# 标签页
keybind = cmd+t=new_tab
keybind = cmd+shift+left=previous_tab
keybind = cmd+shift+right=next_tab
keybind = cmd+w=close_surface

# 分屏
keybind = cmd+d=new_split:right
keybind = cmd+shift+d=new_split:down
keybind = cmd+alt+left=goto_split:left
keybind = cmd+alt+right=goto_split:right
keybind = cmd+alt+up=goto_split:top
keybind = cmd+alt+down=goto_split:bottom

# 字体大小
keybind = cmd+plus=increase_font_size:1
keybind = cmd+minus=decrease_font_size:1
keybind = cmd+zero=reset_font_size

# 全局热键:下拉终端
keybind = global:ctrl+grave_accent=toggle_quick_terminal

# 分屏管理
keybind = cmd+shift+e=equalize_splits
keybind = cmd+shift+f=toggle_split_zoom

# 重载配置
keybind = cmd+shift+comma=reload_config

# ===========================
# === 性能 ===
# ===========================
scrollback-limit = 25000000
EOF

小结

Ghostty 几十行配置覆盖日常所需,纯文本文件天然适合备份迁移。上面那段 cat > ... << 'EOF' 命令就是最简单的”还原脚本”——换电脑后打开终端粘贴执行,完事。


Ghostty 终端使用技巧
http://bestcrr.com/2026/07/17/ghostty终端使用技巧/
作者
Newman liu
发布于
2026年7月17日
许可协议