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

相关推荐
进击的荆棘19 小时前
Linux网络——应用层协议HTTP
linux·运维·服务器·网络·http
jipinxiaofeihua21 小时前
(文章7) 04章-C++异常处理(下)
linux·运维·网络
cpolar技术支持21 小时前
rsync 只看「大小 + 修改时间」:源文件改成 `CCCC-v3`、目标还是 `DDDD-v4`,三条同步命令 rc 全是 0
linux·rsync·cpolar·nas·数据同步
Rsingstarzengjx1 天前
第三十九章 Linux PWM 驱动实验
linux·运维·服务器
SeanQhl1 天前
BoostKit 环境准备
linux·openeuler·鲲鹏·boostkit·软件源
笔记本note2 天前
Linux 内存管理
linux·服务器·内存管理
郝学胜-神的一滴2 天前
Effective STL 条款 14:用扩容函数避免重新分配
linux·开发语言·网络·数据结构·c++·单片机
GeW2 天前
入行 Linux 与数据库运维:一条路径、三项习惯、一个考证观
linux·数据库
南子北游2 天前
Linux 进程状态全景(上)
linux·运维·服务器
无奈笑天下2 天前
银河麒麟高级服务器操作系统【配置 sudo 操作日志记录】操作方法
linux·运维·服务器