版本: 基于 Ghostty 1.2.0+ 官方文档整理
更新时间: 2026年2月
📋 目录
- 配置文件位置
- 基础配置
- 外观主题
- 字体设置
- 窗口行为
- 键盘快捷键
- 高级功能
- macOS 专属配置
- Linux/GTK 专属配置
- 实用配置示例
配置文件位置
macOS
1
| ~/Library/Application Support/com.mitchellh.ghostty/config
|
Linux
1 2 3
| $XDG_CONFIG_HOME/ghostty/config # 或 ~/.config/ghostty/config
|
配置语法说明
- 使用
key = value 格式
# 开头为注释
- 布尔值:
true / false
- 颜色格式:
#RRGGBB 或 X11 颜色名
- 支持多行配置相同选项实现 fallback
基础配置
Shell 设置
1 2 3 4 5 6 7 8 9 10 11 12 13
| command = /bin/zsh
initial-command = /opt/homebrew/bin/fish
window-inherit-working-directory = true working-directory = inherit
env = EDITOR=nvim env = LANG=zh_CN.UTF-8
|
滚动回滚
1 2 3 4 5
| scrollback-limit = 10000000
scroll-to-bottom-on-input = keystroke
|
外观主题
主题选择
1 2 3 4 5 6 7 8
| theme = catppuccin-mocha
theme = light:Rose Pine Dawn,dark:Rose Pine
theme = /path/to/my-theme
|
颜色配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| foreground = background =
background-opacity = 0.95 background-blur = true unfocused-split-opacity = 0.8
cursor-color = cursor-text =
selection-background = selection-foreground =
palette = 0= palette = 1= palette = 2= palette = 3=
|
背景图片(1.2.0+)
1 2 3 4 5
| background-image = /path/to/wallpaper.png background-image-opacity = 0.3 background-image-position = center background-image-fit = cover background-image-repeat = false
|
字体设置
基础字体
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| font-family = JetBrains Mono font-family = Maple Mono
font-family-bold = JetBrains Mono Bold font-family-italic = JetBrains Mono Italic font-family-bold-italic = JetBrains Mono Bold Italic
font-size = 13
font-variation = wght=450
|
字体特性
1 2 3 4 5 6 7 8 9 10 11 12 13
| font-feature = -calt font-feature = -liga font-feature = -dlig
font-style = no-bold,no-italic
adjust-cell-height = 10% adjust-cell-baseline = 2 adjust-underline-position = 1 adjust-underline-thickness = 1
|
字体渲染
1 2 3 4 5
| alpha-blending = linear-corrected
freetype-load-flags = hinting,force-autohint
|
窗口行为
窗口尺寸与位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| window-width = 120 window-height = 35
window-position-x = 100 window-position-y = 100
window-padding-x = 8 window-padding-y = 8 window-padding-balance = true window-padding-color = background
fullscreen = false
|
窗口装饰
1 2 3 4 5 6
| window-decoration = auto
tab-bar = auto tab-position = top
|
窗口状态
1 2 3 4 5 6 7 8 9 10
| window-save-state = default
window-inherit-font-size = true window-inherit-working-directory = true
confirm-close-surface = true quit-after-last-window-closed = false
|
键盘快捷键
快捷键语法
1 2
| keybind = <trigger>=<action> keybind = <trigger>=<action>:<parameter>
|
常用快捷键配置
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
| keybind = ctrl+shift+c=copy_to_clipboard keybind = ctrl+shift+v=paste_from_clipboard
keybind = ctrl+shift+n=new_window keybind = ctrl+shift+t=new_tab
keybind = ctrl+shift+d=new_split:right keybind = ctrl+shift+minus=new_split:down keybind = ctrl+shift+w=close_surface
keybind = ctrl+tab=next_tab keybind = ctrl+shift+tab=previous_tab keybind = ctrl+1=goto_tab:1 keybind = ctrl+2=goto_tab:2
keybind = ctrl+plus=increase_font_size:1 keybind = ctrl+minus=decrease_font_size:1 keybind = ctrl+0=reset_font_size
keybind = f12=toggle_quick_terminal
keybind = ctrl+shift+r=reload_config
|
快捷键前缀修饰符
1 2 3 4 5 6 7 8 9 10 11
| keybind = global:ctrl+grave=toggle_quick_terminal
keybind = all:ctrl+l=clear_screen
keybind = unconsumed:ctrl+a=reload_config
keybind = performable:ctrl+c=copy_to_clipboard
|
序列快捷键(Leader Key)
1 2 3 4
| keybind = ctrl+a>n=new_tab keybind = ctrl+a>d=new_split:right keybind = ctrl+a>q=quit
|
高级功能
鼠标设置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| mouse-click-timeout = 500
mouse-right-click = context-menu
mouse-shift-capture = false
mouse-scroll-multiplier = 3
clipboard-read = allow clipboard-write = allow copy-on-select = true
|
链接与高亮
1 2 3 4 5 6
| link-url = true link-url-previews = true
|
图像协议
1 2
| image-storage-limit = 320MB
|
提示音
1 2 3
| bell-features = attention,title bell-audio-path = /path/to/sound.wav bell-audio-volume = 0.5
|
自定义着色器(GLSL)
1 2
| custom-shader = /path/to/shader.glsl custom-shader-animation = true
|
着色器 Uniform 变量:
iChannel0 - 终端屏幕纹理
iResolution - 输出尺寸
iTime / iTimeDelta - 时间
iCurrentCursor - 当前光标信息
iPreviousCursor - 上一帧光标信息
macOS 专属配置
标题栏样式
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| macos-titlebar-style = transparent
macos-titlebar-buttons = visible
macos-titlebar-proxy-icon = visible
macos-non-native-fullscreen = false
macos-window-shadow = true
|
Option 键行为
1 2
| macos-option-as-alt = true
|
Dock 与应用切换器
1 2 3 4 5 6
| macos-hidden = never
macos-auto-secure-input = true macos-secure-input-indicator = true
|
应用图标自定义
1 2 3 4 5 6 7 8 9 10 11 12
| macos-icon = blueprint
macos-icon = custom-style macos-icon-frame = aluminum macos-icon-ghost-color = macos-icon-screen-color =
macos-icon = custom macos-custom-icon = ~/.config/ghostty/Ghostty.icns
|
快捷指令集成
快速终端(Quake 模式)
1 2 3 4 5 6
| quick-terminal-position = top quick-terminal-size = 50%,100% quick-terminal-screen = main quick-terminal-animation-duration = 0.2 quick-terminal-autohide = true quick-terminal-space-behavior = move
|
Linux/GTK 专属配置
单实例模式
1
| gtk-single-instance = detect
|
标签页设置
1 2 3 4 5 6 7 8
| gtk-tabs-location = top
gtk-wide-tabs = true
gtk-titlebar-hide-when-maximized = false
|
标题栏样式
1
| gtk-titlebar-style = native
|
标签栏外观
1
| gtk-adwaita-toolbar-style = flat
|
自定义 CSS
1
| gtk-css = /path/to/custom.css
|
桌面通知
1 2 3
| gtk-desktop-notifications = true notification = clipboard-copy notification = no-config-reload
|
Cgroup 隔离(资源管理)
1 2 3 4
| linux-cgroup = single-instance linux-cgroup-memory-limit = 1GB linux-cgroup-processes-limit = 100 linux-cgroup-hard-fail = false
|
实用配置示例
🎨 开发环境推荐配置
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
| theme = catppuccin-mocha background-opacity = 0.95 background-blur = true
font-family = JetBrainsMono Nerd Font font-family = Maple Mono CN font-size = 13 font-feature = -calt
window-padding-x = 8 window-padding-y = 8 window-width = 120 window-height = 35
command = /opt/homebrew/bin/fish window-inherit-working-directory = true
keybind = ctrl+shift+t=new_tab keybind = ctrl+shift+d=new_split:right keybind = ctrl+shift+minus=new_split:down keybind = f12=toggle_quick_terminal
|
🖥️ 极简透明风格
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| theme = "" background = background-opacity = 0.85 background-blur = true window-decoration = false
window-padding-x = 0 window-padding-y = 0 window-padding-balance = true
font-family = SF Mono font-size = 12 font-thicken = false
|
⌨️ Vim 用户优化
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| keybind = ctrl+a>n=new_tab keybind = ctrl+a>d=new_split:right keybind = ctrl+a>s=new_split:down keybind = ctrl+a>h=goto_split:left keybind = ctrl+a>j=goto_split:bottom keybind = ctrl+a>k=goto_split:top keybind = ctrl+a>l=goto_split:right
keybind = ctrl+h=unbind keybind = ctrl+j=unbind keybind = ctrl+k=unbind keybind = ctrl+l=unbind
|
🔒 安全优先配置
1 2 3 4 5 6 7 8 9
| clipboard-read = ask clipboard-write = ask title-report = false confirm-close-surface = always
clipboard-read = deny clipboard-write = deny
|
常用 CLI 命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| ghostty +list-themes
ghostty +list-fonts
ghostty +list-actions
ghostty +validate-config
ghostty +show-config
ghostty --config-file=/path/to/config
ghostty --font-size=15 --theme="Dracula"
|
故障排除
配置热重载
修改配置文件后,使用以下方式重新加载:
- 快捷键:
ctrl+shift+r(如果配置了)
- 菜单:Ghostty → Reload Configuration
- 命令:
killall -USR1 ghostty
调试配置问题
1 2 3 4 5
| ghostty --log-level=debug
GTK_DEBUG=interactive ghostty
|
常见问题
Q: 字体显示模糊?
A: 尝试调整 alpha-blending = native 或 font-thicken = true
Q: 透明背景无效?
A: 确保 background-opacity < 1,某些桌面环境可能需要额外配置
Q: 快捷键不生效?
A: 检查是否有 global: 前缀需要系统权限,或使用 ghostty +list-actions 确认动作名称
💡 提示: 本文档基于 Ghostty 1.2.0 版本编写,部分功能可能需要更新版本支持。建议定期查看官方文档获取最新信息。