为什么选它
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 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
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-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' 命令就是最简单的”还原脚本”——换电脑后打开终端粘贴执行,完事。