treeru.com
CLAUDE CODE

Zellij Upgrade for Claude Code SSH — Why I Switched from tmux

2026-04-08
Treeru

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

Session exists → attach (resume work)
Session doesn't exist → create new
Third argument 3 → open with three-pane layout

Save 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
fi
chmod +x ~/.local/bin/zj
ArgumentDescriptionDefault
FirstSession nameai
SecondStarting directory~/ai
Third3 = three-pane layout1 (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.

01

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.

02

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.

03

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.

04

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.

tmuxzellij
Copy methodEnter copy mode → shortcutDrag → Ctrl+C
ResizeOccasional lagInstant response
StabilityOccasional display glitchesRust memory safety
Config learning curveHigh (.tmux.conf)Low (defaults work)
LanguageCRust

Frequently Used Commands

CLI Commands

CommandDescription
zLaunch zellij
z lsList sessions
z a sessionAttach to session
z k sessionKill session
z kaKill all sessions
z daDelete all sessions

In-Session Shortcuts

ShortcutDescription
Ctrl+p → arrow keysMove between panes
Ctrl+nNew pane
Ctrl+tNew tab
Ctrl+qDetach (session stays running)

Wrap-up

ItemDetails
Core valueKeep Claude Code sessions alive through SSH drops + one-click resume
Toolszellij 0.44.1 + zj script + Windows bat files
Advantages over tmuxResize responsiveness, intuitive copy, Rust-based stability
GotchaUse -n flag when combining session name + layout
Install time per serverUnder 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.

T

Treeru

Sharing practical insights on web development, IT infrastructure, and AI solutions. Treeru — your partner in digital transformation.

Share

Comments

(4)
4.88/ 5

Log in to leave a comment.

2026-04-12
555.0

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.

2026-04-11
4.554.5

split_direction working opposite to its name is truly confusing. vertical = horizontal split? Thanks for the heads-up.

2026-04-10
555.0

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.