用途
ghostty-config 用于配置和优化 Ghostty 终端模拟器,帮助按照最佳实践与 XDG Base Directory 规范完成设置。它覆盖从初始搭建到主题、字体、快捷键、性能与行为调整等任务。
主要能力
配置文件位置
Ghostty 遵循 XDG 规范:
- 主配置:~/.config/ghostty/config
- 主题文件:~/.config/ghostty/themes/
字体配置
示例:
font-family = "JetBrains Mono"
font-size = 13
font-family-bold = "JetBrains Mono"
font-family-italic = "JetBrains Mono"
font-feature = -calt
# font-variation = wght=450
指南:使用 Unicode 覆盖良好的等宽字体;字号 12–14 便于阅读;考虑连字偏好(编码与终端工作);提交前测试字体渲染。
主题与外观
示例:
theme = "catppuccin-mocha"
background = #1e1e2e
foreground = #cdd6f4
cursor-color = #f5e0dc
background-opacity = 0.95
background-blur-radius = 20 # 仅 macOS/KDE
window-padding-x = 4
window-padding-y = 4
window-decoration = true
最佳实践:可从内置主题开始,如 catppuccin-、solarized-、gruvbox-*;不透明度建议 ≥ 0.85 以保证可读性;可用背景模糊兼顾美观与清晰;内边距可按工作流取舍。
键位绑定
语法:keybind = trigger=action。
常见模式示例:
keybind = ctrl+shift+h=goto_split:left
keybind = ctrl+shift+j=goto_split:bottom
keybind = ctrl+shift+k=goto_split:top
keybind = ctrl+shift+l=goto_split:right
keybind = ctrl+shift+enter=new_split:right
keybind = ctrl+shift+\=new_split:down
keybind = super+t=new_tab
keybind = super+w=close_surface
keybind = super+1=goto_tab:1
keybind = super+2=goto_tab:2
keybind = super+c=copy_to_clipboard
keybind = super+v=paste_from_clipboard
keybind = super+plus=increase_font_size:1
keybind = super+minus=decrease_font_size:1
keybind = super+0=reset_font_size
keybind = global:super+grave=toggle_quick_terminal
keybind = ctrl+shift+n=unbind
高级特性:
keybind = global:super+shift+t=new_window
keybind = ctrl+a>c=new_window
keybind = all:ctrl+shift+r=reload_config
keybind = unconsumed:ctrl+space=text:\x00
keybind = performable:super+c=copy_to_clipboard
修饰键别名:ctrl = control;alt = opt = option;super = cmd = command。 按键类型:Unicode 码点(ö、é、⌘);物理键(W3C 代码,如 KeyA、Digit1);功能键(F1、F12);特殊键(escape、enter、tab、backspace)。
Shell 集成
shell-integration = detect
shell-integration-features = cursor,sudo,title
command = /usr/bin/fish
env = EDITOR=nvim
env = TERM=xterm-256color
性能与行为
scrollback-limit = 10000
mouse-scroll-multiplier = 3
copy-on-select = clipboard
window-save-state = default
window-inherit-working-directory = true
window-new-tab-position = current
使用方式
配置流程:
- 读取现有配置 ~/.config/ghostty/config(若存在)。
- 根据用户需求确定变更。
- 使用 Edit 做增量修改,或用 Write 创建新配置或大幅重写。
- 校验语法:检查修饰键拼写(ctrl、shift、alt、super)、动作名称(参考官方文档)、INI 格式是否正确。
- 测试建议:提示“变更仅对新终端/窗口生效”,建议重启 Ghostty 或打开新窗口;涉及全局键位时,在 macOS 上需提及辅助功能权限。
常见任务示例:
完整初始设置:
font-family = "JetBrains Mono"
font-size = 13
theme = "catppuccin-mocha"
background-opacity = 0.95
shell-integration = detect
command = /usr/bin/fish
copy-on-select = clipboard
window-inherit-working-directory = true
添加 Vim 风格导航:
keybind = ctrl+h=goto_split:left
keybind = ctrl+j=goto_split:bottom
keybind = ctrl+k=goto_split:top
keybind = ctrl+l=goto_split:right
主题切换:
theme = catppuccin-mocha # 暗色
theme = catppuccin-latte # 亮色
theme = /Users/user/.config/ghostty/themes/custom.conf
Quick Terminal 设置:
keybind = global:super+grave=toggle_quick_terminal
quick-terminal-position = top
quick-terminal-screen = main
quick-terminal-animation-duration = 0.2
参考文档:
- 主配置:https://ghostty.org/docs/config/reference
- 键位绑定:https://ghostty.org/docs/config/keybind
- 列出所有可用动作与默认值:
ghostty +list-keybinds --default
与 dotfiles 集成(本仓库遵循 XDG 规范):
- 存储配置:config/ghostty/config
- 软链接到 XDG 位置:
ln -sf ~/Development/dotfiles/config/ghostty ~/.config/ghostty - 更新 link-config.sh 以包含 Ghostty
- 在 README 的 tools 部分添加说明
输出格式:使用代码块清晰展示变更;解释非显而易见设置的缘由;相关时提供测试命令;说明运行时行为(如“重启 Ghostty 或打开新窗口查看变更”);使用 file:line 格式给出文件路径便于导航。
适用场景
- 首次搭建并创建 Ghostty 基础配置
- 调整主题、字体与外观(透明度、内边距、窗口装饰)
- 定制快捷键、分屏与标签导航、全局与多键序列
- 配置 Shell 集成与自定义 shell、环境变量
- 调整滚动缓冲、鼠标行为、窗口与标签行为
- 设置下拉式 Quick Terminal
- 在 dotfiles 中按 XDG 规范管理并软链接 Ghostty 配置
限制
本技能资料仅覆盖 Ghostty 配置文件编写与优化相关命令与示例;未提供安装步骤、收费与价格、跨平台支持范围、性能效果承诺等信息,暂未提供。