Ubuntu 下 Kitty 终端配置记录

Ubuntu 下 Kitty 终端配置记录

Ubuntu 下 Kitty 终端配置记录

最近把 Ubuntu 默认终端换成了 Kitty,主要看中它的 GPU 加速、原生分屏、Tab、主题以及丰富的快捷键。

我的环境:

text 复制代码
Ubuntu 20.04
Kitty 0.47.0
FiraCode Nerd Font Mono
X11 + fcitx

Kitty 配置文件位于:

bash 复制代码
~/.config/kitty/kitty.conf

可以使用:

bash 复制代码
vim ~/.config/kitty/kitty.conf

进行修改。

基础配置

conf 复制代码
# 性能
input_delay 0
repaint_delay 2
sync_to_monitor no
scrollback_lines 10000
cursor_blink_interval 0

# 字体
font_family FiraCode Nerd Font Mono
font_size 12.0
bold_font auto
italic_font auto

# 窗口
remember_window_size yes
initial_window_width 1600
initial_window_height 900

分屏配置

Kitty 想实现类似 tmux / Terminator 的自由分屏,需要使用 splits layout。

conf 复制代码
enabled_layouts splits

# 左右分屏
map alt+\ launch --location=vsplit

# 上下分屏
map alt+- launch --location=hsplit

# 调整当前窗口大小
map ctrl+shift+r start_resizing_window

# 关闭当前分屏
map ctrl+shift+w close_window

这里需要注意:

text 复制代码
vsplit → 左右分屏
hsplit → 上下分屏

例如:

text 复制代码
Alt + \

┌──────────┬──────────┐
│          │          │
│    1     │    2     │
│          │          │
└──────────┴──────────┘

而:

text 复制代码
Alt + -

┌─────────────────────┐
│          1          │
├─────────────────────┤
│          2          │
└─────────────────────┘

一个踩过的坑

enabled_layouts 的正确写法是:

conf 复制代码
enabled_layouts splits

不要写成:

conf 复制代码
enabled_layouts_splits

否则 Kitty 不会进入 splits 布局,可能出现第一次总是上下分、后续窗口又全部排列在下面的情况。

另外不要写:

conf 复制代码
launch --type=split

因为 split 并不是 launch --type 的合法参数。

正确写法就是:

conf 复制代码
launch --location=vsplit
launch --location=hsplit

Tab 配置

conf 复制代码
map ctrl+shift+t new_tab
map ctrl+tab next_tab
map ctrl+shift+tab previous_tab

map alt+1 goto_tab 1
map alt+2 goto_tab 2
map alt+3 goto_tab 3
map alt+4 goto_tab 4
map alt+5 goto_tab 5

这样可以像浏览器一样使用多个 Tab。

鼠标复制和粘贴

我比较喜欢"选中自动复制,右键直接粘贴":

conf 复制代码
copy_on_select clipboard
mouse_map right press ungrabbed paste_from_clipboard

操作方式:

text 复制代码
左键拖动选择文字 → 自动复制
右键             → 粘贴

键盘仍然可以使用:

text 复制代码
Ctrl + Shift + C    复制
Ctrl + Shift + V    粘贴

URL Hints

Kitty 可以直接识别终端里的 URL:

conf 复制代码
map ctrl+shift+e kitten hints --type url

按:

text 复制代码
Ctrl + Shift + E

即可选择并打开当前终端中的链接。

Kitty Themes

Kitty 自带主题选择器:

bash 复制代码
kitten themes

或者:

bash 复制代码
kitty +kitten themes

选择主题后,通常会在配置中加入:

conf 复制代码
# BEGIN_KITTY_THEME
include current-theme.conf
# END_KITTY_THEME

实用默认快捷键

text 复制代码
Ctrl + Shift + F2    编辑 kitty.conf
Ctrl + Shift + F5    重新加载配置
Ctrl + Shift + F6    查看配置

Ctrl + Shift + G     查看上一条命令输出
Ctrl + Shift + H     查看终端历史
Ctrl + Shift + /     搜索终端历史

Ctrl + Shift + T     新建 Tab
Ctrl + Shift + W     关闭当前 pane

最终配置

目前我的 kitty.conf 核心配置如下:

conf 复制代码
# Performance
input_delay 0
repaint_delay 2
sync_to_monitor no
scrollback_lines 10000
cursor_blink_interval 0

# Font
font_family FiraCode Nerd Font Mono
font_size 12.0
bold_font auto
italic_font auto

# Window
remember_window_size yes
initial_window_width 1600
initial_window_height 900

# Splits
enabled_layouts splits

map alt+\ launch --location=vsplit
map alt+- launch --location=hsplit

map ctrl+shift+r start_resizing_window
map ctrl+shift+w close_window

# Tabs
map ctrl+shift+t new_tab
map ctrl+tab next_tab
map ctrl+shift+tab previous_tab

map alt+1 goto_tab 1
map alt+2 goto_tab 2
map alt+3 goto_tab 3
map alt+4 goto_tab 4
map alt+5 goto_tab 5

# Clipboard
copy_on_select clipboard
mouse_map right press ungrabbed paste_from_clipboard

# Hints
map ctrl+shift+e kitten hints --type url

# Theme
include current-theme.conf

总结

Kitty 真正比较实用的地方并不只是 GPU 加速,而是它可以把:

text 复制代码
分屏
Tab
Shell
日志查看
复制粘贴
主题
Hints

整合在一个终端里。

对于日常 Linux 开发来说,一套简单的 splits + Tab + 快捷键 配置就已经非常舒服了。

参考:https://blog.csdn.net/gitblog_00387/article/details/150816121

相关推荐
weipt1 小时前
利用wsl给windows电脑上安装一个ubuntu
linux·运维·ubuntu
xiaoye-duck2 小时前
《Linux 网络编程》深入理解 TCP 协议(二):序号、确认应答与流量控制机制详解
linux·网络·tcp
楚疏笃2 小时前
linux下给OpenCloudOS根目录扩容
linux·运维·服务器
dog2502 小时前
网络的时延抖动
linux·运维·网络
阿钱真强道2 小时前
01 嵌入式操作系统 | 课程导论与虚拟机安装 Ubuntu
linux·ubuntu·嵌入式·虚拟机
程序员-Benothing2 小时前
Linux 软件包管理:yum / apt / dnf 命令使用全解析
linux·运维·服务器
GeW2 小时前
拿RHCE证书只是起点:这样备考,顺便把真实运维能力也练了
linux
stellanke2 小时前
Linux网络编程实战2:TCP Socket 基础与实践
linux·网络·c++
DigitalOcean3 小时前
Omarchy 将研发基础设施迁移至 DigitalOcean 云平台
linux·agent