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
Quick reference for Zellij CLI commands. Covers session management, tabs, panes, programmatic control, and layouts.
When NOT to use:
Ctrl+B (enters Tmux mode for tab switching)Ctrl+JCtrl+SCtrl+F1-9 to switch tabs| Task | Command |
|---|---|
| New session | zellij -s <name> |
| New session (detached) | zellij attach -b <name> |
| Create or attach | zellij attach -c <name> or zellij attach --create <name> |
| List sessions | zellij list-sessions or zellij ls |
| Attach to session | zellij attach <name> or zellij a <name> |
| Kill session | zellij kill-session <name> or zellij k <name> |
| Delete exited session | zellij delete-session <name> |
| Kill all sessions | zellij kill-all-sessions --yes |
| Delete all exited | zellij delete-all-sessions |
| Task | Command |
|---|---|
| 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> |
| Next/prev tab | zellij action go-to-next-tab / go-to-previous-tab |
| Task | Command |
|---|---|
| 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> |
| Move focus | zellij action move-focus left|right|up|down |
| Toggle floating | zellij action toggle-floating-panes |
| Toggle fullscreen | zellij action toggle-fullscreen-focus |
| List panes | zellij action list-panes |
| Task | Command |
|---|---|
| Run in new pane | zellij run -- <command> |
| Run floating | zellij run -f -- <command> |
| Run with direction | zellij run --direction down -- <command> |
| Close on exit | zellij run -c -- <command> |
| Start suspended | zellij run -s -- <command> |
| Named pane | zellij run -n "build" -- <command> |
| In-place (replace pane) | zellij run -i -- <command> |
| Sized floating | zellij run -f --width 80% --height 80% -- <command> |
| Task | Command |
|---|---|
| Edit file | zellij edit <file> |
| Edit floating | zellij edit -f <file> |
| Edit at line | zellij edit -l 42 <file> |
# 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
# 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
zellij action switch-mode locked # Pass-through mode
zellij action switch-mode normal # Back to normal
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
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
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
| Variable | Description |
|---|---|
ZELLIJ | Set to 0 inside a session (use for nesting prevention) |
ZELLIJ_SESSION_NAME | Current session name |
Wrong: Using new-pane --horizontal
Correct: --direction down (not --horizontal)
Wrong: Confusing toggle with create
toggle-floating-panes = show/hide existing floating panesnew-pane --floating = create NEW floating paneWrong: Forgetting action subcommand
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
zellij action switch-mode normal$'command\n'zellij action commands work inside or outside a session-- to separate pane command from zellij optionsright, left, up, down80%)-s <session> flag to target specific sessions when automating