Zellij Upgrade for Claude Code SSH — Why I Switched from tmux
I previously covered tmux + Claude Code SSH session management. tmux worked well for a long time, but at some point I switched to zellij. Setup is simpler, and there are noticeable differences in a Claude Code workflow.
This post covers everything: zellij installation, the automation script, one-click access from Windows, and a bug I ran into along the way.
zellij 0.44.1
Version used
5 min
Install time per server
One-click
Windows bat access
Rust
Memory safety guaranteed
Why You Need a Terminal Multiplexer
Claude Code runs in the terminal. When you use it over SSH, a dropped connection kills the session — your conversation, the file being edited, the running build. All gone.
Close laptop lid → SSH drops → Claude Code session destroyed
Brief WiFi disconnect → SSH timeout → in-progress work lost
Accidentally close terminal → full context reset
A terminal multiplexer (tmux, zellij) keeps the session alive as a server-side process. When SSH drops, the session keeps running. Reconnect, and you pick up exactly where you left off.
# Without multiplexer (SSH drops = game over) Windows Terminal → SSH → Claude Code # With zellij (session survives SSH drops) Windows Terminal → SSH → zellij session → Claude Code
Installing Zellij
Downloading the binary directly is the simplest approach. No package manager dependencies — works the same on any Linux server.
# x86_64 Linux (v0.44.1) curl -sL https://github.com/zellij-org/zellij/releases/download/v0.44.1/zellij-x86_64-unknown-linux-musl.tar.gz \ | tar xz -C /usr/local/bin/ # Without sudo — install to user directory mkdir -p ~/.local/bin curl -sL https://github.com/zellij-org/zellij/releases/download/v0.44.1/zellij-x86_64-unknown-linux-musl.tar.gz \ | tar xz -C ~/.local/bin/
Verify after install:
zellij --version # zellij 0.44.1
Registering the z Shortcut
Typing zellij every time gets old. Add one alias to ~/.bashrc:
alias z="zellij"
Common commands become short:
z # launch zellij z ls # list sessions z a myses # attach to session z k myses # kill session
zj Auto-Attach Script
This script attaches to an existing session or creates a new one. Run it after SSHing in, and you're immediately back in your working environment.
How it works
attach (resume work)3 → open with three-pane layoutSave as ~/.local/bin/zj:
#!/bin/bash
SESSION="${1:-ai}"
DIR="${2:-~/ai}"
PANES="${3:-1}"
# Auto-detect zellij location
if command -v zellij &>/dev/null; then
ZJ=zellij
elif [ -x "$HOME/.local/bin/zellij" ]; then
ZJ="$HOME/.local/bin/zellij"
elif [ -x /usr/local/bin/zellij ]; then
ZJ=/usr/local/bin/zellij
else
echo "zellij not found"; exit 1
fi
LAYOUT_FILE="$HOME/.config/zellij/layouts/three.kdl"
cd "$DIR"
if $ZJ list-sessions 2>/dev/null | grep -q "$SESSION"; then
$ZJ attach "$SESSION"
else
if [ "$PANES" = "3" ] && [ -f "$LAYOUT_FILE" ]; then
$ZJ -s "$SESSION" -n "$LAYOUT_FILE"
else
$ZJ -s "$SESSION"
fi
fichmod +x ~/.local/bin/zj
| Argument | Description | Default |
|---|---|---|
| First | Session name | ai |
| Second | Starting directory | ~/ai |
| Third | 3 = three-pane layout | 1 (single) |
Three-Pane Layout
Run Claude Code, watch build output, and do manual work — all in one view. Zellij layouts are defined in KDL format.
~/.config/zellij/layouts/three.kdl:
layout {
pane split_direction="vertical" {
pane
pane
pane
}
}split_direction caveat
In zellij, split_direction="vertical" means horizontal splits (panes stacked top to bottom). This is opposite to what the name implies. For side-by-side panes, use split_direction="horizontal".
One-Click Access with Windows bat Files
This bat file opens a new Windows Terminal tab, SSHes into the server, and attaches to the zellij session — all in one step. Make one per server and double-click to jump straight into any working environment.
@echo off wt nt cmd /k ssh -t server-alias "/home/user/.local/bin/zj session-name ~/project-folder 3"
Practical example:
@echo off wt nt cmd /k ssh -t myserver "/home/user/.local/bin/zj dev ~/project 3"
About wt nt
wt nt opens a new Windows Terminal tab. The existing window stays open, and a new tab connects to the target server. With five servers, five bat files means five double-clicks to reach any working environment instantly.
Known Bug: -s + --layout Combination
On zellij 0.44.1, combining a session name with a layout file behaves differently depending on the flag used.
# Broken — session created but layout not applied zellij -s mysession --layout three # Works — session name + layout applied together zellij -s mysession -n three
Key takeaway
Use -n (--new-session-with-layout), not --layout. Without this, you get the confusing symptom of "session starts but only one pane appears." The zj script above uses -n to avoid this.
SSH PATH Problem and Fix
When you run a command directly over SSH (ssh server "command"), a non-login shell opens. ~/.bashrc aliases and PATH additions don't apply, so zj and zellij show up as "command not found."
Auto-detect in the script
The zj script searches for zellij in common locations without relying on PATH
Use absolute paths in the bat file
Calling /home/user/.local/bin/zj explicitly bypasses PATH entirely
4 Reasons I Switched from tmux
Practical differences after switching from years of tmux usage.
Terminal Resize Handling
tmux sometimes lags or shifts layout when the window is resized. Zellij reacts immediately. With Claude Code producing heavy output, this difference is more noticeable. A small thing, but it adds up over a full day of work.
Text Copy Behavior
tmux requires entering copy mode → yellow highlight → shortcut key to copy. Zellij works like a normal terminal: drag → Ctrl+C. When grabbing code snippets or error messages from Claude Code output, you can use your existing habits without learning new shortcuts.
Long-Term Stability
Running multiple tmux sessions for extended periods can occasionally produce display glitches or state corruption. Zellij is written in Rust, which provides memory safety guarantees at the language level. Running it across multiple servers simultaneously over many hours hasn't produced any issues.
Fit with Claude Code Workflow
Session recovery (SSH drops → reconnect → continue), parallel view (Claude Code + build log + manual work in one screen), long-term stability (keep running all day without issues) — zellij handles all three more reliably than tmux. That's the core reason for switching.
| tmux | zellij | |
|---|---|---|
| Copy method | Enter copy mode → shortcut | Drag → Ctrl+C |
| Resize | Occasional lag | Instant response |
| Stability | Occasional display glitches | Rust memory safety |
| Config learning curve | High (.tmux.conf) | Low (defaults work) |
| Language | C | Rust |
Frequently Used Commands
CLI Commands
| Command | Description |
|---|---|
z | Launch zellij |
z ls | List sessions |
z a session | Attach to session |
z k session | Kill session |
z ka | Kill all sessions |
z da | Delete all sessions |
In-Session Shortcuts
| Shortcut | Description |
|---|---|
| Ctrl+p → arrow keys | Move between panes |
| Ctrl+n | New pane |
| Ctrl+t | New tab |
| Ctrl+q | Detach (session stays running) |
Wrap-up
| Item | Details |
|---|---|
| Core value | Keep Claude Code sessions alive through SSH drops + one-click resume |
| Tools | zellij 0.44.1 + zj script + Windows bat files |
| Advantages over tmux | Resize responsiveness, intuitive copy, Rust-based stability |
| Gotcha | Use -n flag when combining session name + layout |
| Install time per server | Under 5 minutes |
If tmux is working for you, there's no urgent reason to switch. But if copy behavior feels awkward or resize is sluggish in your SSH + Claude Code setup, zellij is worth trying. Install takes 5 minutes, and it just works out of the box.
Comments
(4)Log in to leave a comment.
Per-server bat files for one-click access is a great pattern. I've got 8 servers — setting one up for each now. The absolute path fix for SSH PATH is clean.
split_direction working opposite to its name is truly confusing. vertical = horizontal split? Thanks for the heads-up.
Lost 30 minutes to the -s + --layout bug before. Turns out -n was the fix all along. Would've saved so much time if I'd seen this first.
Related Posts
© 2026 TreeRU. All rights reserved.
All content is copyrighted by TreeRU. Unauthorized reproduction without attribution is prohibited.