Terminal Workspaces
Terminal Workspaces
Editors change buffers. Workspaces change how long processes live, how many shells you juggle, and whether closing a laptop kills a four-hour test or an AI agent.
This chapter is the shared mental model for tmux, screen, Zellij, and Herdr. Dedicated chapters go deeper; modern-tools covers Zellij in the CLI toolkit chapter.
Problems workspaces solve
| Problem | Without workspace | With workspace |
|---|---|---|
| SSH disconnect | Shells die | Detach; processes continue |
| Many tasks | Terminal tabs on the client only | Server-side panes/windows |
| Pairing / reattach | Lost context | Named sessions |
| AI agents | One agent per terminal window; easy to lose | Herdr tracks agent state across panes |
| Layout | Rebuild every login | Scripted layouts |
Choosing among multiplexers
Need maximum portability on random servers?
└─ tmux (or screen if tmux missing)
Want nicer defaults and layouts without much config?
└─ Zellij
Running Claude Code / Codex / opencode / other agent CLIs?
└─ Herdr (can still live inside or beside tmux)
Only local GUI terminal tabs?
└─ Fine for simple work; still learn tmux for remote
When not to nest
Avoid:
tmux → herdr → tmux → nvim
Prefer one outer session manager:
herdr
├─ nvim
├─ agent
└─ shell
# or
tmux
├─ nvim
├─ shell
└─ optional: herdr only if you need agent UI features
Herdr docs note it can run inside tmux as the outer terminal environment, but agent detection does not inspect tmux sessions launched inside a Herdr pane. Keep the layering intentional.
Editor integration patterns
Pattern A — editor full window
Window 1: nvim
Window 2: shell / tests
Window 3: docs / top
Simple; great with Vim tabs/buffers for files.
Pattern B — editor + shell split
Pane left: hx or nvim
Pane right: cargo test / npm run dev
Classic pair-programming-with-yourself layout.
Pattern C — agent herd (Herdr)
Workspace "api"
Tab agents: Claude Code | Codex | opencode
Tab runtime: dev server | logs
Herdr surfaces working / blocked / idle so you jump to the agent that needs input.
Pattern D — remote box
ssh build-box
tmux attach -t build || tmux new -s build
# or
herdr --remote build-boxCopy mode and scrollback
Terminal multiplexers own scrollback. Mouse scrolling may enter copy-mode.
tmux essentials:
Ctrl-b [ # copy mode
# move with vi keys if mode-keys vi
Space / Enter # start/end selection (emacs mode defaults vary)
Ctrl-b ] # paste bufferConfigure vi keys:
# ~/.tmux.conf
set -g mode-keys vi
set -g status-keys vi
Persistence expectations
| Event | tmux/screen/Zellij | Herdr |
|---|---|---|
| Close terminal emulator | Session survives if server running | Server keeps panes |
| SSH drop | Session survives | Session survives |
| Reboot | Dead unless you script restore | Layout restore / agent resume features (see Herdr docs) |
kill-server / stop |
Everything dies | Everything dies |
Do not assume reboot survival without explicit tooling (systemd user services, tmux-resurrect, Herdr session state features).
Minimal practice lab
# 1. Session
tmux new -s lab
# 2. Split
Ctrl-b % # vertical split
Ctrl-b " # horizontal split
Ctrl-b o # next pane
# 3. Run something long
ping -c 1000 1.1.1.1
# 4. Detach and kill the terminal window entirely
Ctrl-b d
# 5. Prove it lived
tmux attach -t labThen repeat a similar flow after reading the tmux and Herdr parts.
Keybindings to keep conflict-free
If you use Vim/Neovim:
- Prefer tmux prefix
Ctrl-b(default) orCtrl-aonly if you rebind screen habits carefully - In Neovim, avoid binding the same chords tmux uses without
passthrough - For Helix/Zed, conflicts are fewer; still test copy-mode and pane zoom
Next chapters
- tmux — the portable standard for SSH and long jobs
- Herdr — agent-native workspaces and CLI/API
- Workflows — concrete editor + multiplexer recipes
- Modern tools — Zellij, prompts, file jumpers, git pagers
The workspace layer is not optional once your work outlives a single shell. Learn detach/attach early; everything else is efficiency.