zellij

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Zellij Reference

Zellij 参考文档

Overview

概述

Quick reference for Zellij CLI commands to manipulate running sessions. Covers session management, tabs, and panes.
用于操作运行中会话的Zellij CLI命令快速参考,涵盖会话管理、标签页和窗格相关操作。

When to Use

适用场景

  • Creating or attaching to Zellij sessions
  • Managing tabs and panes programmatically
  • Need CLI commands (not keybindings)
  • Automating Zellij operations
When NOT to use:
  • Looking for keybindings (this is CLI only)
  • Layout file syntax
  • Configuration options
  • 创建或连接到Zellij会话
  • 以编程方式管理标签页和窗格
  • 需要使用CLI命令(而非快捷键)
  • 自动化Zellij操作
不适用场景:
  • 查找快捷键(本文档仅涉及CLI)
  • 布局文件语法
  • 配置选项

Quick Reference

快速参考

Sessions

会话

TaskCommand
Create/attach session
zellij attach --create <name>
or
zellij -s <name>
List sessions
zellij list-sessions
Kill session
zellij kill-session <name>
Delete session
zellij delete-session <name>
操作任务命令
创建/连接会话
zellij attach --create <name>
zellij -s <name>
列出会话
zellij list-sessions
终止会话
zellij kill-session <name>
删除会话
zellij delete-session <name>

Tabs

标签页

TaskCommand
New tab
zellij action new-tab
New tab with name
zellij action new-tab --name <name>
New tab with cwd
zellij action new-tab --cwd <path>
New tab with layout
zellij action new-tab --layout <layout>
Close tab
zellij action close-tab
Rename tab
zellij action rename-tab <name>
Go to tab by name
zellij action go-to-tab-name <name>
Go to tab by index
zellij action go-to-tab <index>
操作任务命令
新建标签页
zellij action new-tab
新建带名称的标签页
zellij action new-tab --name <name>
新建指定工作目录的标签页
zellij action new-tab --cwd <path>
新建指定布局的标签页
zellij action new-tab --layout <layout>
关闭标签页
zellij action close-tab
重命名标签页
zellij action rename-tab <name>
通过名称切换到标签页
zellij action go-to-tab-name <name>
通过索引切换到标签页
zellij action go-to-tab <index>

Panes

窗格

TaskCommand
New pane (auto)
zellij action new-pane
Split right
zellij action new-pane --direction right
Split down
zellij action new-pane --direction down
Floating pane
zellij action new-pane --floating
Floating with size
zellij action new-pane --floating --width 80% --height 60%
Pane with command
zellij action new-pane -- <command>
Close pane
zellij action close-pane
Rename pane
zellij action rename-pane <name>
操作任务命令
自动新建窗格
zellij action new-pane
向右拆分窗格
zellij action new-pane --direction right
向下拆分窗格
zellij action new-pane --direction down
新建浮动窗格
zellij action new-pane --floating
新建指定大小的浮动窗格
zellij action new-pane --floating --width 80% --height 60%
新建执行指定命令的窗格
zellij action new-pane -- <command>
关闭窗格
zellij action close-pane
重命名窗格
zellij action rename-pane <name>

Common Patterns

常见使用模式

New tab for specific task:
bash
zellij action new-tab --name "backend" --cwd ~/api
Split pane and run command:
bash
zellij action new-pane --direction down -- npm run dev
New pane with guaranteed working directory:
bash
undefined
为特定任务新建标签页:
bash
zellij action new-tab --name "backend" --cwd ~/api
拆分窗格并运行命令:
bash
zellij action new-pane --direction down -- npm run dev
新建指定工作目录的窗格:
bash
undefined

For interactive shell with specific directory

带指定目录的交互式shell

zellij action new-pane --cwd /path/to/dir
zellij action new-pane --cwd /path/to/dir

For command that must run in specific directory

必须在指定目录运行的命令

zellij action new-pane --cwd /path/to/dir -- sh -c 'cd /path/to/dir && your-command'
zellij action new-pane --cwd /path/to/dir -- sh -c 'cd /path/to/dir && your-command'

For nvim that must start in specific directory

必须在指定目录启动的nvim

zellij action new-pane --cwd /path/to/worktree -- sh -c 'cd /path/to/worktree && nvim'

**Floating scratch terminal:**
```bash
zellij action new-pane --floating --width 90% --height 90%
zellij action new-pane --cwd /path/to/worktree -- sh -c 'cd /path/to/worktree && nvim'

**新建浮动临时终端:**
```bash
zellij action new-pane --floating --width 90% --height 90%

Common Mistakes

常见错误

❌ Using
new-pane --horizontal
Correct:
--direction down
(not
--horizontal
)
❌ Confusing toggle with create
  • toggle-floating-panes
    = show/hide existing floating panes
  • new-pane --floating
    = create NEW floating pane
❌ Forgetting
action
subcommand
Wrong:
zellij new-tab
Right:
zellij action new-tab
❌ Pane not starting in correct directory Problem: Using
--cwd
alone doesn't always ensure the command runs in that directory
bash
undefined
❌ 使用
new-pane --horizontal
正确用法:
--direction down
(而非
--horizontal
❌ 混淆切换与创建操作
  • toggle-floating-panes
    = 显示/隐藏已有的浮动窗格
  • new-pane --floating
    = 创建新的浮动窗格
❌ 忘记
action
子命令
错误写法:
zellij new-tab
正确写法:
zellij action new-tab
❌ 窗格未在指定目录启动 问题:仅使用
--cwd
并不总能确保命令在该目录运行
bash
undefined

❌ Wrong - nvim might not start in the right directory

❌ 错误写法 - nvim可能不会在正确目录启动

zellij action new-pane --cwd /path/to/worktree -- nvim
zellij action new-pane --cwd /path/to/worktree -- nvim

✅ Correct - explicitly cd first

✅ 正确写法 - 先显式切换目录

zellij action new-pane --cwd /path/to/worktree -- sh -c 'cd /path/to/worktree && nvim'
undefined
zellij action new-pane --cwd /path/to/worktree -- sh -c 'cd /path/to/worktree && nvim'
undefined

Notes

注意事项

  • All
    zellij action
    commands work inside or outside a session
  • Use
    --
    to separate pane command from zellij options
  • Direction options:
    right
    ,
    left
    ,
    up
    ,
    down
  • Size units: bare integers or percentages (e.g.,
    80%
    )
  • 所有
    zellij action
    命令在会话内部或外部均可使用
  • 使用
    --
    分隔窗格命令与Zellij选项
  • 方向选项包括:
    right
    left
    up
    down
  • 尺寸单位:纯数字或百分比(例如:
    80%