简介
Kitty 是一款基于 GPU 加速的现代终端模拟器,使用 OpenGL 渲染文本,性能极为出色。其配置文件位于 ~/.config/kitty/kitty.conf,采用简洁的 key value 语法。Kitty 支持连字字体、图片显示、多窗口布局等高级特性,非常适合追求性能与美观并重的用户。
本文提供一份经过精心调整的完整配置,覆盖字体、光标、滚动、鼠标、窗口布局、标签栏、配色和快捷键等核心模块,可直接使用或作为定制起点。
完整配置
# ============================================================
# ~/.config/kitty/kitty.conf — Kitty 终端配置
# ============================================================
# ---------- 1. 字体设置 ----------
# 主字体(推荐使用 Nerd Font 以支持图标)
font_family JetBrainsMono Nerd Font
bold_font auto
italic_font auto
bold_italic_font auto
# 字号大小
font_size 14.0
# 调整行距和字符间距(单位:pt)
adjust_line_height 2
adjust_column_width 0
# 启用连字支持(JetBrains Mono 等字体支持 -> != >=)
disable_ligatures never
# ---------- 2. 光标设置 ----------
# 光标形状:block(方块)| beam(竖线)| underline(下划线)
cursor_shape beam
# 光标闪烁间隔(秒),设为 0 禁用闪烁
cursor_blink_interval 0.5
# 光标颜色(none 表示跟随文本前景色)
cursor none
# Shell 集成时停止闪烁
cursor_stop_blinking_after 15.0
# ---------- 3. 滚动设置 ----------
# 回滚缓冲区行数(-1 为无限)
scrollback_lines 10000
# 用于 scrollback_pager 的内存限制(MB)
scrollback_pager_history_size 64
# 使用 less 作为回滚分页器
scrollback_pager less --chop-long-lines --RAW-CONTROL-CHARS +INPUT_LINE_NUMBER
# 滚动速度(每次滚轮滚动的行数)
wheel_scroll_multiplier 5.0
# 触控板滚动速度
touch_scroll_multiplier 1.0
# ---------- 4. 鼠标设置 ----------
# 点击链接时打开浏览器
open_url_with default
# 检测 URL 并允许点击打开
detect_urls yes
# URL 下划线样式
url_style curly
# 链接颜色
url_color #61afef
# 鼠标隐藏延迟(秒),0 表示不隐藏
mouse_hide_wait 3.0
# 复制到剪贴板时同时复制到选区(类 X11 行为)
copy_on_select clipboard
# ---------- 5. 窗口布局 ----------
# 支持的布局:fat, grid, horizontal, splits, stack, tall, vertical
enabled_layouts splits, stack, tall, fat
# 窗口内边距(pt)
window_padding_width 8
# 窗口边框宽度
window_border_width 1pt
# 活动窗口边框颜色
active_border_color #61afef
# 非活动窗口边框颜色
inactive_border_color #3e4452
# 非活动窗口文字透明度(1.0 为不透明)
inactive_text_alpha 0.7
# 新窗口默认尺寸(字符列 x 行)
remember_window_size yes
initial_window_width 120c
initial_window_height 36c
# 窗口装饰(titlebar-only 在 macOS 上仅显示标题栏按钮)
hide_window_decorations no
# macOS 标题栏颜色跟随主题
macos_titlebar_color background
# ---------- 6. 标签栏设置 ----------
# 标签栏位置:top | bottom
tab_bar_edge bottom
# 标签栏样式:fade | slant | separator | powerline | custom | hidden
tab_bar_style powerline
# Powerline 样式的分隔符形状
tab_powerline_style slanted
# 标签标题模板
tab_title_template "{index}: {title}"
# 活动标签标题模板
active_tab_title_template "{index}: {title} *"
# 活动标签样式
active_tab_foreground #282c34
active_tab_background #61afef
active_tab_font_style bold
# 非活动标签样式
inactive_tab_foreground #abb2bf
inactive_tab_background #3e4452
inactive_tab_font_style normal
# 标签栏背景色
tab_bar_background #21252b
# ---------- 7. 配色方案 (One Dark 风格) ----------
# 前景与背景
foreground #abb2bf
background #282c34
# 背景透明度(需要合成器支持)
background_opacity 0.95
# 选区颜色
selection_foreground #282c34
selection_background #61afef
# 标准 16 色
# 黑色
color0 #282c34
color8 #5c6370
# 红色
color1 #e06c75
color9 #e06c75
# 绿色
color2 #98c379
color10 #98c379
# 黄色
color3 #e5c07b
color11 #e5c07b
# 蓝色
color4 #61afef
color12 #61afef
# 品红
color5 #c678dd
color13 #c678dd
# 青色
color6 #56b6c2
color14 #56b6c2
# 白色
color7 #abb2bf
color15 #ffffff
# ---------- 8. 声音与通知 ----------
# 关闭响铃声音
enable_audio_bell no
# 窗口闪烁提示
visual_bell_duration 0.0
# 响铃时在标签栏显示标记
bell_on_tab "🔔 "
# ---------- 9. 快捷键绑定 ----------
# 清除所有默认快捷键(可选,按需取消注释)
# clear_all_shortcuts yes
# -- 剪贴板 --
map ctrl+shift+c copy_to_clipboard
map ctrl+shift+v paste_from_clipboard
# -- 字体缩放 --
map ctrl+shift+equal change_font_size all +1.0
map ctrl+shift+minus change_font_size all -1.0
map ctrl+shift+0 change_font_size all 0
# -- 窗口管理 --
# 新建窗口(splits 布局下水平/垂直分屏)
map ctrl+shift+enter new_window_with_cwd
map ctrl+shift+\ launch --location=vsplit --cwd=current
map ctrl+shift+- launch --location=hsplit --cwd=current
# 窗口切换(Vim 风格)
map ctrl+shift+h neighboring_window left
map ctrl+shift+l neighboring_window right
map ctrl+shift+k neighboring_window up
map ctrl+shift+j neighboring_window down
# 窗口大小调整
map ctrl+shift+r start_resizing_window
# 切换布局
map ctrl+shift+space next_layout
# -- 标签页管理 --
map ctrl+shift+t new_tab_with_cwd
map ctrl+shift+w close_tab
map ctrl+shift+right next_tab
map ctrl+shift+left previous_tab
map ctrl+shift+. move_tab_forward
map ctrl+shift+, move_tab_backward
# 按编号切换标签页
map ctrl+shift+1 goto_tab 1
map ctrl+shift+2 goto_tab 2
map ctrl+shift+3 goto_tab 3
map ctrl+shift+4 goto_tab 4
map ctrl+shift+5 goto_tab 5
# -- 滚动 --
map ctrl+shift+up scroll_line_up
map ctrl+shift+down scroll_line_down
map ctrl+shift+page_up scroll_page_up
map ctrl+shift+page_down scroll_page_down
map ctrl+shift+home scroll_home
map ctrl+shift+end scroll_end
# -- 其他 --
# 重新加载配置
map ctrl+shift+f5 load_config_file
# 打开 Kitty Shell(调试用)
map ctrl+shift+escape kitty_shell window
# 查看快捷键帮助
map ctrl+shift+f1 show_kitty_doc overview
# ---------- 10. 高级设置 ----------
# Shell 集成(提供命令行编辑增强)
shell_integration enabled
# 允许远程控制(通过 kitty @ 命令控制 Kitty)
allow_remote_control socket-only
listen_on unix:/tmp/mykitty
# 确认关闭窗口(-1 = 有进程运行时询问)
confirm_os_window_close -1
# 剪贴板最大大小(MB)
clipboard_max_size 512
# 更新检查间隔(小时),0 禁用
update_check_interval 0
配置说明
字体与渲染
Kitty 原生支持 OpenType 连字,配合 JetBrains Mono 等编程字体可显示 ->, !=, >= 等连字效果。adjust_line_height 可微调行距,让长时间阅读更舒适。
窗口布局
enabled_layouts 指定可用的布局模式。splits 布局支持自由水平/垂直分屏,stack 可将窗口全屏切换,tall 和 fat 提供主从式布局。通过 Ctrl+Shift+Space 在已启用的布局间循环切换。
标签栏
Powerline 风格的标签栏美观且信息丰富。tab_title_template 支持变量替换,可显示标签索引、窗口标题、进程名等。
远程控制
开启 allow_remote_control 后,可通过 kitty @ 命令在脚本中远程控制 Kitty 实例,例如 kitty @ set-colors background=#1e1e2e 动态切换配色。
常用技巧
- 快速预览图片:在 Kitty 中执行
kitty +kitten icat image.png可直接在终端内显示图片,无需额外工具。 - SSH 复用:使用
kitty +kitten ssh user@host代替普通 ssh,可自动将 Kitty 的 terminfo 传递到远程机器,避免显示异常。 - 字体回退链:如果需要显示中文或特殊符号,可通过
symbol_map指定 Unicode 范围到特定字体的映射,例如symbol_map U+4E00-U+9FFF Noto Sans CJK SC。 - 会话恢复:使用
kitty --session ~/.config/kitty/session.conf启动预定义的窗口/标签布局,适合每天重复的工作流。 - 主题切换:Kitty 内置主题管理器,执行
kitty +kitten themes可交互式浏览和切换数百款配色方案。 - 调试配置:执行
kitty --debug-config可查看所有非默认的配置项,快速定位配置问题。