ghostty-config
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGhostty Configuration
Ghostty 配置
Guidance for configuring the Ghostty terminal emulator. Ghostty uses text-based config files with sensible defaults and zero required configuration.
Ghostty终端模拟器配置指南。Ghostty采用基于文本的配置文件,拥有合理的默认设置,且无需强制配置。
Config File Locations
配置文件位置
XDG Path (All Platforms):
$XDG_CONFIG_HOME/ghostty/config- Defaults to if XDG_CONFIG_HOME undefined
~/.config/ghostty/config
macOS Additional Path:
~/Library/Application Support/com.mitchellh.ghostty/config- If both XDG and macOS paths exist, both are loaded with macOS path taking precedence
XDG路径(全平台):
$XDG_CONFIG_HOME/ghostty/config- 如果未定义XDG_CONFIG_HOME,则默认路径为
~/.config/ghostty/config
macOS额外路径:
~/Library/Application Support/com.mitchellh.ghostty/config- 若XDG路径和macOS路径同时存在,两者都会被加载,且macOS路径优先级更高
Config Syntax
配置语法
undefinedundefinedComments start with
注释以#开头
background = 282c34
foreground = ffffff
font-family = "JetBrains Mono"
keybind = ctrl+z=close_surface
font-family = # Empty value resets to default
**Rules:**
- Keys are **case-sensitive** (use lowercase)
- Whitespace around `=` is flexible
- Values can be quoted or unquoted
- Empty values reset to defaults
- Every config key works as CLI flag: `ghostty --background=282c34`background = 282c34
foreground = ffffff
font-family = "JetBrains Mono"
keybind = ctrl+z=close_surface
font-family = # 空值会重置为默认值
**规则:**
- 键名区分大小写(请使用小写)
- `=`两侧的空格可灵活调整
- 值可以加引号或不加引号
- 空值会重置为默认设置
- 所有配置键均可作为CLI标志使用:`ghostty --background=282c34`Config Loading & Includes
配置加载与引入
Files processed sequentially - later entries override earlier ones.
undefined配置文件按顺序处理 - 后续条目会覆盖之前的条目。
undefinedInclude additional configs
引入额外配置文件
config-file = themes/dark.conf
config-file = ?local.conf # ? prefix = optional (no error if missing)
**Critical:** `config-file` directives are processed at the file's end. Keys appearing after `config-file` won't override the included file's values.config-file = themes/dark.conf
config-file = ?local.conf # ?前缀表示可选(文件不存在时不会报错)
**重要提示:**`config-file`指令会在文件末尾处理。出现在`config-file`之后的配置键不会覆盖引入文件中的值。Runtime Reloading
运行时重载
- Linux:
ctrl+shift+, - macOS:
cmd+shift+,
Some options cannot be reloaded at runtime. Some apply only to newly created terminals.
- Linux:
ctrl+shift+, - macOS:
cmd+shift+,
部分选项无法在运行时重载,部分选项仅对新创建的终端生效。
CLI Commands
CLI命令
Ghostty provides CLI actions via . Use for action-specific help.
ghostty +<action>ghostty +<action> --helpGhostty通过提供CLI操作。使用查看操作的专属帮助信息。
ghostty +<action>ghostty +<action> --helpConfiguration Commands
配置相关命令
| Command | Description |
|---|---|
| Show current effective configuration |
| Show default configuration |
| Show defaults with documentation |
| Validate configuration file for errors |
| Open config file in default editor |
| 命令 | 描述 |
|---|---|
| 显示当前生效的配置 |
| 显示默认配置 |
| 显示带文档说明的默认配置 |
| 验证配置文件是否存在错误 |
| 在默认编辑器中打开配置文件 |
Listing Commands
列表类命令
| Command | Description |
|---|---|
| List available fonts (fixed-width) |
| List available colour themes |
| Show current keybindings |
| Show default keybindings |
| List available colour names |
| List all available keybinding actions |
| 命令 | 描述 |
|---|---|
| 列出可用的等宽字体 |
| 列出可用的配色主题 |
| 显示当前的快捷键绑定 |
| 显示默认的快捷键绑定 |
| 列出可用的颜色名称 |
| 列出所有可用的快捷键绑定操作 |
Other Commands
其他命令
| Command | Description |
|---|---|
| Show version information |
| Show help |
| Show font face information |
| Manage SSH terminfo cache |
| Generate crash report |
| Open new window (Linux only) |
| Easter egg |
| 命令 | 描述 |
|---|---|
| 显示版本信息 |
| 显示帮助信息 |
| 显示字体外观信息 |
| 管理SSH terminfo缓存 |
| 生成崩溃报告 |
| 打开新窗口(仅Linux支持) |
| 复活节彩蛋 |
Launching with Options
带选项启动
Every config key works as a CLI flag:
bash
ghostty --background=282c34 --font-size=14
ghostty -e top # Run command in terminalmacOS Note: The CLI is a helper tool. To launch the terminal use or .
ghosttyopen -na Ghostty.appopen -na Ghostty.app --args --font-size=14所有配置键均可作为CLI标志使用:
bash
ghostty --background=282c34 --font-size=14
ghostty -e top # 在终端中运行指定命令macOS注意事项: CLI是一个辅助工具。要启动终端,请使用或。
ghosttyopen -na Ghostty.appopen -na Ghostty.app --args --font-size=14Keybinding Syntax
快捷键绑定语法
Format:
keybind = trigger=action格式:
keybind = 触发键=操作Triggers
触发键
Modifiers: , /, //, //
shiftctrlcontrolaltoptoptionsupercmdcommandkeybind = ctrl+a=select_all
keybind = ctrl+shift+t=new_tab
keybind = super+backquote=toggle_quick_terminalPhysical keys (W3C codes): , , ,
KeyAkey_aDigit1BracketLeft- Physical keys have higher priority than unicode codepoints
- Use for non-US keyboard layouts
Key sequences (leader keys):
keybind = ctrl+a>n=new_window # Press ctrl+a, release, press n
keybind = ctrl+a>ctrl+n=new_window # Both with ctrlSequences wait indefinitely for next key.
修饰键:, /, //, //
shiftctrlcontrolaltoptoptionsupercmdcommandkeybind = ctrl+a=select_all
keybind = ctrl+shift+t=new_tab
keybind = super+backquote=toggle_quick_terminal物理键(W3C编码):, , ,
KeyAkey_aDigit1BracketLeft- 物理键的优先级高于Unicode码点
- 适用于非美式键盘布局
按键序列(引导键):
keybind = ctrl+a>n=new_window # 先按ctrl+a,松开后按n
keybind = ctrl+a>ctrl+n=new_window # 两次都按住ctrl序列会无限等待下一个按键输入。
Prefixes
前缀
| Prefix | Effect |
|---|---|
| System-wide (macOS: needs Accessibility permissions; Linux: needs XDG Desktop Portal) |
| Apply to all terminal surfaces |
| Don't consume input (passes through) |
| Only consume if action succeeds |
Combine prefixes:
global:unconsumed:ctrl+a=reload_configNote: Sequences cannot be used with or prefixes.
global:all:| 前缀 | 效果 |
|---|---|
| 系统全局生效(macOS:需要辅助功能权限;Linux:需要XDG Desktop Portal) |
| 应用于所有终端界面 |
| 不消耗输入(会传递给下层) |
| 仅在操作成功时才消耗输入 |
可组合前缀:
global:unconsumed:ctrl+a=reload_config**注意:**按键序列无法与或前缀一起使用。
global:all:Special Values
特殊值
- - Remove ALL keybindings
keybind = clear - - Remove specific binding
keybind = ctrl+a=unbind - - Prevent processing by Ghostty and terminal
keybind = ctrl+a=ignore
- - 移除所有快捷键绑定
keybind = clear - - 移除指定的快捷键绑定
keybind = ctrl+a=unbind - - 阻止Ghostty和终端处理该按键
keybind = ctrl+a=ignore
Shell Integration
Shell集成
Auto-injection for: bash, zsh, fish, elvish
shell-integration = detect # Default - auto-detect shell
shell-integration = none # Disable auto-injection
shell-integration = fish # Force specific shell自动注入支持:bash, zsh, fish, elvish
shell-integration = detect # 默认值 - 自动检测Shell类型
shell-integration = none # 禁用自动注入
shell-integration = fish # 强制指定Shell类型Shell Integration Features
Shell集成功能
shell-integration-features = cursor,sudo,title
shell-integration-features = no-cursor # Disable specific feature| Feature | Description |
|---|---|
| Blinking bar at prompt |
| Preserve terminfo with sudo |
| Set window title from shell |
| SSH environment compatibility |
| Auto terminfo on remote hosts |
shell-integration-features = cursor,sudo,title
shell-integration-features = no-cursor # 禁用特定功能| 功能 | 描述 |
|---|---|
| 在提示符处显示闪烁光标 |
| 使用sudo时保留terminfo信息 |
| 根据Shell设置窗口标题 |
| SSH环境兼容性 |
| 在远程主机上自动配置terminfo |
What Shell Integration Enables
Shell集成带来的功能
- Smart close (no confirm when at prompt)
- New terminals start in previous terminal's directory
- Prompt resizing via redraw
- Ctrl/Cmd+triple-click selects command output
- keybinding works
jump_to_prompt - Alt/Option+click repositions cursor at prompt
- 智能关闭(在提示符位置时无需确认)
- 新终端会在之前终端的目录中启动
- 通过重绘调整提示符大小
- Ctrl/Cmd+三击选中命令输出
- 快捷键绑定生效
jump_to_prompt - Alt/Option+点击可将光标定位到提示符处
Manual Setup (if auto-injection fails)
手动配置(自动注入失败时)
Bash (add to at top):
~/.bashrcbash
if [ -n "${GHOSTTY_RESOURCES_DIR}" ]; then
builtin source "${GHOSTTY_RESOURCES_DIR}/shell-integration/bash/ghostty.bash"
fiZsh:
zsh
source ${GHOSTTY_RESOURCES_DIR}/shell-integration/zsh/ghostty-integrationFish:
fish
source "$GHOSTTY_RESOURCES_DIR"/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fishmacOS Note: does NOT support automatic shell integration. Install Bash via Homebrew or manually source the script.
/bin/bashBash(添加到顶部):
~/.bashrcbash
if [ -n "${GHOSTTY_RESOURCES_DIR}" ]; then
builtin source "${GHOSTTY_RESOURCES_DIR}/shell-integration/bash/ghostty.bash"
fiZsh:
zsh
source ${GHOSTTY_RESOURCES_DIR}/shell-integration/zsh/ghostty-integrationFish:
fish
source "$GHOSTTY_RESOURCES_DIR"/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fishmacOS注意事项:不支持自动Shell集成。请通过Homebrew安装Bash,或手动引入脚本。
/bin/bashCommon Configuration Patterns
常见配置模式
Theme with Light/Dark Mode
明暗主题切换
theme = light:catppuccin-latte,dark:catppuccin-mochatheme = light:catppuccin-latte,dark:catppuccin-mochaQuick Terminal (Drop-down)
快速终端(下拉式)
quick-terminal-position = top
quick-terminal-size = 50%
quick-terminal-autohide = true
keybind = global:super+backquote=toggle_quick_terminalquick-terminal-position = top
quick-terminal-size = 50%
quick-terminal-autohide = true
keybind = global:super+backquote=toggle_quick_terminalCustom Colour Palette
自定义配色方案
palette = 0=#1d2021
palette = 1=#cc241dpalette = 0=#1d2021
palette = 1=#cc241d... (0-255 supported)
...(支持0-255号颜色)
undefinedundefinedFont Configuration
字体配置
font-family = "JetBrains Mono"
font-family-bold = "JetBrains Mono Bold"
font-size = 14
font-feature = -calt # Disable ligatures
font-feature = -ligafont-family = "JetBrains Mono"
font-family-bold = "JetBrains Mono Bold"
font-size = 14
font-feature = -calt # 禁用连字
font-feature = -ligaBackground Transparency
背景透明度
background-opacity = 0.9
background-blur = true # macOS, KDE Plasma onlybackground-opacity = 0.9
background-blur = true # 仅支持macOS、KDE PlasmaPlatform-Specific Notes
平台专属说明
macOS Only:
- ,
window-position-x/y,window-save-statewindow-step-resize - ,
window-vsyncwindow-colorspace - ,
macos-titlebar-styletoggle_window_float_on_top - ,
font-thickenfont-thicken-strength - ,
toggle_visibility,undo,redocheck_for_updates - Global keybindings require Accessibility permissions
Linux/GTK Only:
- ,
window-title-font-familywindow-subtitle - (requires
window-titlebar-background/foreground)window-theme = ghostty - ,
window-show-tab-bargtk-single-instance - ,
toggle_maximizetoggle_window_decorations - ,
toggle_tab_overviewtoggle_command_palette prompt_surface_title
Linux Wayland Only:
quick-terminal-keyboard-interactivity- ,
gtk-quick-terminal-layergtk-quick-terminal-namespace
FreeType (Linux) Only:
freetype-load-flags
仅macOS支持:
- ,
window-position-x/y,window-save-statewindow-step-resize - ,
window-vsyncwindow-colorspace - ,
macos-titlebar-styletoggle_window_float_on_top - ,
font-thickenfont-thicken-strength - ,
toggle_visibility,undo,redocheck_for_updates - 全局快捷键绑定需要辅助功能权限
仅Linux/GTK支持:
- ,
window-title-font-familywindow-subtitle - (需要设置
window-titlebar-background/foreground)window-theme = ghostty - ,
window-show-tab-bargtk-single-instance - ,
toggle_maximizetoggle_window_decorations - ,
toggle_tab_overviewtoggle_command_palette prompt_surface_title
仅Linux Wayland支持:
quick-terminal-keyboard-interactivity- ,
gtk-quick-terminal-layergtk-quick-terminal-namespace
仅FreeType(Linux)支持:
freetype-load-flags
Reference Files
参考文件
For complete option and keybinding references, load:
- - All config options by category (font, colour, window, etc.)
references/options.md - - All keybinding actions with parameters
references/keybindings.md
Load these when you need specific option details, valid values, or keybinding action syntax.
如需完整的选项和快捷键绑定参考,请查看:
- - 按类别划分的所有配置选项(字体、颜色、窗口等)
references/options.md - - 所有带参数的快捷键绑定操作
references/keybindings.md
当你需要了解特定选项的详细信息、有效值或快捷键绑定操作语法时,请查阅这些文件。