Published on

Alacritty + Zellij 终端配置指南

Authors

为什么是 Alacritty + Zellij

Alacritty 是一个 GPU 加速的终端模拟器,性能极好,但设计上故意保持极简,不支持标签页和分屏。

Zellij 是一个现代终端工作区(多路复用器),开箱即带标签页、分屏、浮动面板、插件系统,可以理解为 tmux 的现代替代品。

两者搭配:Alacritty 负责渲染,Zellij 负责窗口管理,是目前最流行的终端组合之一。

安装

# Alacritty (Ubuntu/Debian)
sudo apt install alacritty

# Zellij (通过 cargo 安装)
cargo install --locked zellij

Alacritty 配置

配置文件路径:~/.config/alacritty/alacritty.toml

启动时自动进入 Zellij

[env]
TERM = "xterm-256color"

[terminal]
shell = { program = "/home/clouder/.cargo/bin/zellij" }

这样每次打开 Alacritty 就会自动进入 Zellij。

窗口与字体配置

[window]
padding = { x = 16, y = 16 }
dynamic_padding = true
decorations = "full"
opacity = 0.97

[font]
size = 13.0

[font.normal]
family = "Noto Sans Mono"
style = "Regular"

主题配色:Catppuccin Latte

Alacritty 使用 Catppuccin Latte 浅色主题,颜色如下:

[colors.primary]
background = "#eff1f5"
foreground = "#4c4f69"

[colors.normal]
black = "#5c5f77"
red = "#d20f39"
green = "#40a02b"
yellow = "#df8e1d"
blue = "#1e66f5"
magenta = "#ea76cb"
cyan = "#179299"
white = "#acb0be"

[colors.bright]
black = "#6c6f85"
red = "#d20f39"
green = "#40a02b"
yellow = "#df8e1d"
blue = "#1e66f5"
magenta = "#ea76cb"
cyan = "#179299"
white = "#bcc0cc"

[colors.cursor]
text = "#4c4f69"
cursor = "#dc8a78"

Zellij 配置

配置文件路径:~/.config/zellij/config.kdl

主题配色

Zellij 内置了多个浅色主题,推荐与 Alacritty 配色统一的 catppuccin-latte

theme "catppuccin-latte"
theme_light "catppuccin-latte"

其他可选浅色主题:

主题名风格
catppuccin-latte暖色浅调,和 Alacritty 配色一致
solarized-light经典浅色
gruvbox-light暖色复古
ayu-light清新简洁
iceberg-light柔和冷色
pencil-light高对比度
tokyo-night-light东京之夜浅色版
everforest-light自然绿色调

常见问题:Zellij UI 文字看不清

如果 Zellij 的 Tip 弹窗、状态栏等 UI 元素文字太浅看不清,通常是 Zellij 主题和 Alacritty 终端配色不一致导致的。

Zellij 的 UI 颜色由主题控制,但如果主题配色和终端本身的颜色方案差异较大,就会出现对比度不足的问题。

解决方案是让 Alacritty 和 Zellij 使用统一的主题配色。例如两者都使用 catppuccin-latte

  • Alacritty 配置 Catppuccin Latte 的颜色(见上文)
  • Zellij 配置 theme "catppuccin-latte"

这样两者的背景色、前景色、强调色都保持一致,UI 元素就能清晰显示了。

常用快捷键

快捷键功能
Ctrl+p进入 Pane 模式
Ctrl+p 后按 n新建分屏
Ctrl+p 后按 d向下分屏
Ctrl+p 后按 r向右分屏
Ctrl+p 后按 方向键在分屏间移动
Ctrl+t进入 Tab 模式
Ctrl+t 后按 n新建 Tab
Ctrl+t 后按 1-9跳转到指定 Tab
Ctrl+n进入 Resize 模式
Ctrl+o进入 Session 模式
Ctrl+q退出 Zellij
Alt+f切换浮动面板
Ctrl+s进入 Scroll 模式

会话管理

zellij attach          # 重新连接到之前的会话
zellij list-sessions   # 列出所有会话
zellij kill-session <name>  # 关闭指定会话

TERM 环境变量的作用

TERM 告诉运行在终端里的程序当前终端支持哪些能力(颜色数、光标移动、清屏等)。

  • xterm-256color — 兼容性最好,几乎所有程序都认识,支持 256 色
  • alacritty — Alacritty 自带的 terminfo,声明了完整能力(真彩色、括号粘贴等)

建议:

  • 本地使用 → 设为 alacritty,让程序充分利用特性
  • SSH 远程 → 保持 xterm-256color,因为远程机器可能没有 alacritty 的 terminfo

小结

Alacritty + Zellij 的组合兼顾了性能和易用性。Alacritty 负责 GPU 渲染和主题配色,Zellij 负责标签页、分屏和会话管理。主题上选择 Catppuccin Latte 可以让两者配色统一,视觉体验一致。