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

相关推荐
Felven16 小时前
华为鲲鹏920s芯片serdestool工具使用说明
linux·运维·服务器·华为·鲲鹏920·serdestool
莫晓燚16 小时前
mall 电商项目完整部署---实战
linux·运维·docker·容器
咋的啥名都用不了呢~16 小时前
Linux项目部署5(安装Nginx的插件)
linux
CodeYp201916 小时前
第11讲:应用层协议 HTTP
linux·http
爱和冰阔落16 小时前
【Linux网络】JsonCpp 怎么实现序列化?从 Request/Response 到网络计算器消息设计
linux·运维·网络·php
我是koten1 天前
【运维杂谈】K8s遇到Terminating的名称空间删除不了怎么办?(解决方案亲测有效)
linux·运维·服务器·云原生·kubernetes·k8s·名称空间
2601_967987371 天前
安装 Redis 或 Redis Stack
linux·windows·redis·macos·安装
feng_you_ying_li1 天前
linux之数据链路层
linux·网络·智能路由器
GeW1 天前
高端化走到深处,是数据库和Linux的事
linux
程序员初一1 天前
Linux 远程桌面有四种做法
linux·ssh