版本: 基于 Ghostty 1.2.0+ 官方文档整理更新时间: 2026年2月
📋 目录
配置文件位置
基础配置
外观主题
字体设置
窗口行为
键盘快捷键
高级功能
macOS 专属配置
Linux/GTK 专属配置
实用配置示例
配置文件位置macOS1~/Library/Application Support/com.mitchellh.ghostty/config
Linux123$XDG_CONFIG_HOME/ghostty/config# 或~/.config/ghostty/config
配置语法说明
使用 key = value 格式
# 开头为注释
布尔值:true / false
颜色格式:#RRGGBB 或 X11 颜色名
支持多行配置相同选项实现 fallback
基础配置Shell 设置12345678910111213# 指定启动的 shell(默认自动检测)command = /bin/zsh# 仅首次启动时使用的命令initial-command = /opt/homebrew/bin/fish# 工作目录继承设置window-inherit-working-directory = trueworking-directory = inherit # 可选: home, inherit, 或绝对路径# 环境变量env = EDITOR=nvimenv = LANG=zh_CN.UTF-8
滚动回滚12345# 回滚缓冲区大小(字节),默认无限scrollback-limit = 10000000# 是否自动滚动到底部scroll-to-bottom-on-input = keystroke # keystroke, output, none
外观主题主题选择12345678# 使用内置主题(运行 ghostty +list-themes 查看所有主题)theme = catppuccin-mocha# 亮色/暗色主题分别设置theme = light:Rose Pine Dawn,dark:Rose Pine# 自定义主题文件路径theme = /path/to/my-theme
颜色配置1234567891011121314151617181920212223# 前景色和背景色foreground = #cdd6f4background = #1e1e2e# 透明度设置background-opacity = 0.95 # 0-1 之间background-blur = true # 启用毛玻璃效果unfocused-split-opacity = 0.8 # 非活动分屏透明度# 光标颜色cursor-color = #f38ba8cursor-text = #1e1e2e # 光标下文字颜色# 选中文字颜色selection-background = #353749selection-foreground = #cdd6f4# 256色调色板palette = 0=#45475apalette = 1=#f38ba8palette = 2=#a6e3a1palette = 3=#f9e2af# ... 继续定义 0-255
背景图片(1.2.0+)12345background-image = /path/to/wallpaper.pngbackground-image-opacity = 0.3background-image-position = centerbackground-image-fit = cover # contain, cover, stretch, nonebackground-image-repeat = false
字体设置基础字体1234567891011121314# 主字体(可多次指定实现 fallback)font-family = JetBrains Monofont-family = Maple Mono # Fallback 字体# 特定样式字体font-family-bold = JetBrains Mono Boldfont-family-italic = JetBrains Mono Italicfont-family-bold-italic = JetBrains Mono Bold Italic# 字体大小(点)font-size = 13# 字重调整(可变字体)font-variation = wght=450
字体特性12345678910111213# 禁用编程连字(如将 != 显示为 ≠)font-feature = -caltfont-feature = -ligafont-feature = -dlig# 禁用合成粗体/斜体font-style = no-bold,no-italic# 字形微调adjust-cell-height = 10% # 单元格高度调整adjust-cell-baseline = 2 # 基线位置adjust-underline-position = 1 # 下划线位置adjust-underline-thickness = 1 # 下划线粗细
字体渲染12345# 抗锯齿色彩空间(macOS)alpha-blending = linear-corrected # native, linear, linear-corrected# FreeType 设置(Linux)freetype-load-flags = hinting,force-autohint
窗口行为窗口尺寸与位置12345678910111213141516# 初始窗口大小(字符网格)window-width = 120window-height = 35# 初始窗口位置(像素,macOS 专用)window-position-x = 100window-position-y = 100# 窗口内边距window-padding-x = 8window-padding-y = 8window-padding-balance = true # 平衡四周留白window-padding-color = background # background, extend, extend-always# 全屏设置fullscreen = false
窗口装饰123456# 标题栏样式(通用)window-decoration = auto # auto, client, server, none# 标签页设置tab-bar = auto # always, auto, nevertab-position = top # GTK 专用
窗口状态12345678910# 窗口状态保存window-save-state = default # default, never, always# 新窗口继承设置window-inherit-font-size = truewindow-inherit-working-directory = true# 关闭确认confirm-close-surface = true # true, false, alwaysquit-after-last-window-closed = false
键盘快捷键快捷键语法12keybind =
常用快捷键配置1234567891011121314151617181920212223242526272829# 复制粘贴keybind = ctrl+shift+c=copy_to_clipboardkeybind = ctrl+shift+v=paste_from_clipboard# 新建窗口/标签页keybind = ctrl+shift+n=new_windowkeybind = ctrl+shift+t=new_tab# 分屏操作keybind = ctrl+shift+d=new_split:rightkeybind = ctrl+shift+minus=new_split:downkeybind = ctrl+shift+w=close_surface# 切换标签页keybind = ctrl+tab=next_tabkeybind = ctrl+shift+tab=previous_tabkeybind = ctrl+1=goto_tab:1keybind = ctrl+2=goto_tab:2# 缩放字体keybind = ctrl+plus=increase_font_size:1keybind = ctrl+minus=decrease_font_size:1keybind = ctrl+0=reset_font_size# 快速终端(Quake 模式)keybind = f12=toggle_quick_terminal# 重新加载配置keybind = ctrl+shift+r=reload_config
快捷键前缀修饰符1234567891011# global: - 全局快捷键(即使 Ghostty 未聚焦)keybind = global:ctrl+grave=toggle_quick_terminal# all: - 应用到所有终端表面keybind = all:ctrl+l=clear_screen# unconsumed: - 不消费输入(同时发送给程序)keybind = unconsumed:ctrl+a=reload_config# performable: - 仅在可执行时生效keybind = performable:ctrl+c=copy_to_clipboard
序列快捷键(Leader Key)1234# 类似 Vim 的 leader keykeybind = ctrl+a>n=new_tabkeybind = ctrl+a>d=new_split:rightkeybind = ctrl+a>q=quit
高级功能鼠标设置12345678910111213141516# 鼠标点击超时(毫秒)mouse-click-timeout = 500# 右键菜单行为mouse-right-click = context-menu # context-menu, paste, copy, copy-or-paste, ignore# Shift+点击行为mouse-shift-capture = false # true, false, always, never# 滚轮滚动倍数mouse-scroll-multiplier = 3# 选中文本自动复制clipboard-read = allow # ask, allow, denyclipboard-write = allow # ask, allow, denycopy-on-select = true
链接与高亮123456# URL 识别与打开link-url = truelink-url-previews = true # 显示链接预览# 自定义链接匹配(暂不可用)# link = regex:pattern,action:open
图像协议12# Kitty 图像协议内存限制image-storage-limit = 320MB # 每个屏幕的最大图像数据
提示音123bell-features = attention,title # system, audio, attention, title, borderbell-audio-path = /path/to/sound.wavbell-audio-volume = 0.5
自定义着色器(GLSL)12custom-shader = /path/to/shader.glslcustom-shader-animation = true # true, false, always
着色器 Uniform 变量:
iChannel0 - 终端屏幕纹理
iResolution - 输出尺寸
iTime / iTimeDelta - 时间
iCurrentCursor - 当前光标信息
iPreviousCursor - 上一帧光标信息
macOS 专属配置标题栏样式1234567891011121314# 标题栏风格macos-titlebar-style = transparent # native, transparent, tabs, hidden# 窗口按钮macos-titlebar-buttons = visible # visible, hidden# 代理图标(当前文件夹图标)macos-titlebar-proxy-icon = visible# 非原生全屏macos-non-native-fullscreen = false # true, false, visible-menu, padded-notch# 窗口阴影macos-window-shadow = true
Option 键行为12# 将 Option 视为 Alt 键macos-option-as-alt = true # true, false, left, right
Dock 与应用切换器123456# 隐藏 Dock 图标(适合快速终端用户)macos-hidden = never # never, always# 自动安全输入(密码框)macos-auto-secure-input = truemacos-secure-input-indicator = true
应用图标自定义123456789101112# 预设图标风格macos-icon = blueprint # official, blueprint, chalkboard, microchip, glass, holographic, paper, retro, xray# 自定义样式macos-icon = custom-stylemacos-icon-frame = aluminum # aluminum, beige, plastic, chromemacos-icon-ghost-color = #89b4famacos-icon-screen-color = #1e1e2e,#313244# 完全自定义图标macos-icon = custommacos-custom-icon = ~/.config/ghostty/Ghostty.icns
快捷指令集成1macos-shortcuts = ask # ask, allow, deny
快速终端(Quake 模式)123456quick-terminal-position = top # top, bottom, left, right, centerquick-terminal-size = 50%,100% # 高度,宽度quick-terminal-screen = main # main, mouse, macos-menu-barquick-terminal-animation-duration = 0.2quick-terminal-autohide = truequick-terminal-space-behavior = move # move, remain
Linux/GTK 专属配置单实例模式1gtk-single-instance = detect # true, false, detect
标签页设置12345678# 标签页位置gtk-tabs-location = top # top, bottom, hidden# 标签页样式gtk-wide-tabs = true # true, false# 最大化时隐藏标题栏gtk-titlebar-hide-when-maximized = false
标题栏样式1gtk-titlebar-style = native # native, tabs
标签栏外观1gtk-adwaita-toolbar-style = flat # flat, raised, raised-border
自定义 CSS1gtk-css = /path/to/custom.css
桌面通知123gtk-desktop-notifications = truenotification = clipboard-copy # clipboard-copy, config-reloadnotification = no-config-reload # 禁用某项
Cgroup 隔离(资源管理)1234linux-cgroup = single-instance # never, always, single-instancelinux-cgroup-memory-limit = 1GBlinux-cgroup-processes-limit = 100linux-cgroup-hard-fail = false
实用配置示例🎨 开发环境推荐配置1234567891011121314151617181920212223242526# 主题与外观theme = catppuccin-mochabackground-opacity = 0.95background-blur = true# 字体font-family = JetBrainsMono Nerd Fontfont-family = Maple Mono CNfont-size = 13font-feature = -calt# 窗口window-padding-x = 8window-padding-y = 8window-width = 120window-height = 35# Shellcommand = /opt/homebrew/bin/fishwindow-inherit-working-directory = true# 快捷键keybind = ctrl+shift+t=new_tabkeybind = ctrl+shift+d=new_split:rightkeybind = ctrl+shift+minus=new_split:downkeybind = f12=toggle_quick_terminal
🖥️ 极简透明风格12345678910111213141516# 完全透明theme = ""background = #000000background-opacity = 0.85background-blur = truewindow-decoration = false# 无边框window-padding-x = 0window-padding-y = 0window-padding-balance = true# 细字体font-family = SF Monofont-size = 12font-thicken = false
⌨️ Vim 用户优化1234567891011121314# Leader key 风格快捷键keybind = ctrl+a>n=new_tabkeybind = ctrl+a>d=new_split:rightkeybind = ctrl+a>s=new_split:downkeybind = ctrl+a>h=goto_split:leftkeybind = ctrl+a>j=goto_split:bottomkeybind = ctrl+a>k=goto_split:topkeybind = ctrl+a>l=goto_split:right# 禁用可能与 Vim 冲突的快捷键keybind = ctrl+h=unbindkeybind = ctrl+j=unbindkeybind = ctrl+k=unbindkeybind = ctrl+l=unbind
🔒 安全优先配置123456789# 禁用潜在风险功能clipboard-read = askclipboard-write = asktitle-report = falseconfirm-close-surface = always# OSC 52 剪贴板控制clipboard-read = denyclipboard-write = deny
常用 CLI 命令1234567891011121314151617181920# 列出所有可用主题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
调试配置问题12345# 查看详细日志ghostty --log-level=debug# GTK 调试模式(Linux)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 版本编写,部分功能可能需要更新版本支持。建议定期查看官方文档获取最新信息。