Dotfiles-nix zellij
Use when manipulating Zellij sessions, creating tabs or panes, sending commands to panes, capturing output, or looking up Zellij CLI commands for terminal multiplexer operations
install
source · Clone the upstream repo
git clone https://github.com/not-matthias/dotfiles-nix
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/not-matthias/dotfiles-nix "$T" && mkdir -p ~/.claude/skills && cp -r "$T/modules/home/programs/cli-agents/shared/skills/zellij" ~/.claude/skills/not-matthias-dotfiles-nix-zellij && rm -rf "$T"
manifest:
modules/home/programs/cli-agents/shared/skills/zellij/SKILL.mdsource content
Zellij Reference
Overview
Quick reference for Zellij CLI commands. Covers session management, tabs, panes, programmatic control, and layouts.
When to Use
- Creating or attaching to Zellij sessions
- Managing tabs and panes programmatically
- Sending commands to or reading output from panes
- Running parallel tasks in separate panes
- Automating Zellij operations
When NOT to use:
- Layout file syntax (see layout section below for basics)
- Deep configuration changes (edit zellij.nix directly)
User's Config
- Prefix/Tmux mode:
(enters Tmux mode for tab switching)Ctrl+B - Session manager:
Ctrl+J - Sessionizer:
(zoxide-based)Ctrl+S - Help/forgot:
Ctrl+F - Tab switching: In Tmux mode,
to switch tabs1-9 - Mouse: enabled
- Pane frames: disabled
- Status bar: zjstatus plugin (bottom, 2 lines)
- Session jump: zoxide integration in session manager
Quick Reference
Sessions
| Task | Command |
|---|---|
| New session | |
| New session (detached) | |
| Create or attach | or |
| List sessions | or |
| Attach to session | or |
| Kill session | or |
| Delete exited session | |
| Kill all sessions | |
| Delete all exited | |
Tabs
| Task | Command |
|---|---|
| New tab | |
| New tab with name | |
| New tab with cwd | |
| New tab with layout | |
| Close tab | |
| Rename tab | |
| Go to tab by name | |
| Go to tab by index | |
| Next/prev tab | / |
Panes
| Task | Command |
|---|---|
| New pane (auto) | |
| Split right | |
| Split down | |
| Floating pane | |
| Floating with size | |
| Pane with command | |
| Close pane | |
| Rename pane | |
| Move focus | |
| Toggle floating | |
| Toggle fullscreen | |
| List panes | |
Run Commands in Panes
| Task | Command |
|---|---|
| Run in new pane | |
| Run floating | |
| Run with direction | |
| Close on exit | |
| Start suspended | |
| Named pane | |
| In-place (replace pane) | |
| Sized floating | |
Edit Files in Panes
| Task | Command |
|---|---|
| Edit file | |
| Edit floating | |
| Edit at line | |
Programmatic Control
Sending Text to Panes
# Send text to focused pane (no execution) zellij action write-chars "some text" # Send command with Enter to execute zellij action write-chars $'echo hello\n' # Send to specific session zellij -s my-session action write-chars $'cargo test\n' # Send control characters zellij action write 3 # Ctrl+C zellij action write 4 # Ctrl+D zellij action write 27 # Escape
Capturing Pane Output
# Dump visible pane content to file zellij action dump-screen /tmp/output.txt # Dump with full scrollback history zellij action dump-screen --full /tmp/output.txt # Dump current layout (useful for saving/sharing) zellij action dump-layout
Switch Modes Programmatically
zellij action switch-mode locked # Pass-through mode zellij action switch-mode normal # Back to normal
Common Patterns
New tab for specific task:
zellij action new-tab --name "backend" --cwd ~/api
Split pane and run command:
zellij action new-pane --direction down -- npm run dev
New pane with guaranteed working directory:
# For interactive shell with specific directory 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' # For nvim that must start in specific directory zellij action new-pane --cwd /path/to/worktree -- sh -c 'cd /path/to/worktree && nvim'
Floating scratch terminal:
zellij action new-pane --floating --width 90% --height 90%
Run parallel agents in separate sessions:
# Create detached sessions zellij attach -b agent-1 zellij attach -b agent-2 # Send commands to each zellij -s agent-1 action write-chars $'cd /tmp/project1 && codex "Fix bug X"\n' zellij -s agent-2 action write-chars $'cd /tmp/project2 && codex "Fix bug Y"\n' # Check output zellij -s agent-1 action dump-screen /tmp/agent1-output.txt
Session Resurrection
Zellij auto-saves session state. Exited sessions can be resurrected:
zellij ls # Shows EXITED sessions zellij attach <exited-session> # Resurrect it zellij attach <name> --force-run-commands # Skip "Press ENTER" confirmation zellij delete-session <name> # Permanently remove
Setup Utilities
zellij setup --dump-config # Print default config zellij setup --dump-layout default # Print default layout zellij setup --dump-layout compact # Print compact layout zellij setup --generate-completion fish # Fish completions zellij setup --check # Validate config
Environment Variables
| Variable | Description |
|---|---|
| Set to inside a session (use for nesting prevention) |
| Current session name |
Common Mistakes
Wrong: Using
Correct: new-pane --horizontal
--direction down (not --horizontal)
Wrong: Confusing toggle with create
= show/hide existing floating panestoggle-floating-panes
= create NEW floating panenew-pane --floating
Wrong: Forgetting
subcommand
action
zellij new-tab -> zellij action new-tab
Wrong: Pane not starting in correct directory Using
--cwd alone doesn't always ensure the command runs in that directory:
# Wrong - nvim might not start in the right directory zellij action new-pane --cwd /path -- nvim # Correct - explicitly cd first zellij action new-pane --cwd /path -- sh -c 'cd /path && nvim'
Wrong: Text not appearing in target pane
- Ensure the target pane is focused
- Try switching to normal mode first:
zellij action switch-mode normal - Remember to include newline for execution:
$'command\n'
Notes
- All
commands work inside or outside a sessionzellij action - Use
to separate pane command from zellij options-- - Direction options:
,right
,left
,updown - Size units: bare integers or percentages (e.g.,
)80% - Hold SHIFT to bypass Zellij mouse capture for terminal selection
- Use
flag to target specific sessions when automating-s <session>