Skip to content

Reykjavíksunrise --:--sunset --:--

hire

Rex

A terminal multiplexer my agents can drive, a Mac Mini that never sleeps, and a dev server that opens in its own pane.

5 min read

§Third multiplexer, same idea

I wrote about tmux a couple of years ago. The idea hasn't changed since then: one window, a session per kind of work, and panes I can leave running and come back to.

The tool has changed twice. tmux became Herdr over the summer. I ported my tmux keys to it and set up named sessions for maul, personal and work. Herdr in turn became Rex at the start of November.

Rex calls itself "the multiplexer for all work". It's a terminal, a session server and a CLI. The vocabulary takes a minute: in the CLI a tab is a window and a pane is a block. Everything I can do with the keyboard I can also do with the rex command, and that is the part that matters.

§Why I switched

The trigger was boring. I use a Mac Mini at home as an always-on machine, and I connected to it from the MacBook with Herdr over SSH. That link kept timing out. Rex has remote hosts built in: the server runs on the Mini, the MacBook attaches to it over Tailscale, and sessions keep running on the Mini after I close the lid.

The reason I stayed is different. Rex was built with agents in mind, and I spend most of my day next to Claude Code.

§The Mac Mini as a host

There's no Homebrew formula, so the Mini runs the Rex Beta app. Nobody is logged into the Mini's desktop, which means the app never launches on its own. A system LaunchDaemon starts the server at boot instead:

Shell
# /Library/LaunchDaemons/com.superlogical.rex.server.plist runs, roughly:
rex server --tailscale --tailscale-hostname rex-mini

--tailscale gives Rex its own node on the tailnet, separate from the Mini's Tailscale app. I tried pointing Rex at the Tailscale app first and it couldn't find any tailnet addresses, because it was talking to a stale, logged-out daemon. The built-in node just worked.

On the MacBook I add the Mini once:

Shell
rex hosts add mini https://rex-mini.<tailnet>.ts.net

After that, -S mini sends any command there:

Shell
rex -S mini new scraper
rex -S mini run -- bun run sync

§The config

Rex reads one file, ~/.config/rex/init.lua. Keys are bound with rex.bind, and you can add your own actions in Lua.

My muscle memory is two prefixes deep, so I kept both. Ctrl+B is the tmux layer and Ctrl+S is the Herdr layer:

Ctrl+B+|
Split right (Ctrl+S works too)
Ctrl+B+-
Split down
Ctrl+B+H / J / K / L
Move between panes
Ctrl+S+Shift+R
Resize mode, arrows to resize, Esc to leave
Ctrl+S+( or )
Previous and next session
lua
rex.bind("ctrl+b>shift+\\", "pane.split", { direction = "right" })
rex.bind("ctrl+b>-", "pane.split", { direction = "down" })
rex.bind("ctrl+b>h", "pane.focus", { direction = "left" })

rex.mode("resize", { exclusive = true })
rex.bind("resize/left", "pane.resize", { direction = "left" })
rex.bind("resize/escape", "client.mode.exit")

rex keymap prints every binding with the line in init.lua it came from, which beats grepping a config file.

§Dev servers and tests get their own panes

This is the part I use the most, and the part I couldn't do in tmux without a pile of shell scripts.

I have three custom actions: run_dev, run_tests and run_task. Each opens a pane in a column to the right of the one I'm typing in, dev on top, then tests, then task. Running one again replaces its old pane, so starting the dev server a second time stops the first one and frees the port. A task pane closes itself when the command succeeds and waits for a key when it fails.

The package manager comes from the lockfile:

lua
local function package_manager(dir)
  if exists(dir .. "/bun.lock") or exists(dir .. "/bun.lockb") then return "bun" end
  if exists(dir .. "/pnpm-lock.yaml") then return "pnpm" end
  return "npm"
end

I don't press keys for this most of the time. My .zshrc wraps npm, bun, pnpm and yarn when the shell is inside Rex:

Shell
if [[ -n $REX_BLOCK ]] && (( $+commands[rex] )); then
  rex_pm() {
    local pm=$1 kind; shift
    if kind=$(rex_pane_kind "$@"); then
      rex_pane $kind $pm "$@"
    else
      command $pm "$@"
    fi
  }
  npm() { rex_pm npm "$@"; }
  bun() { rex_pm bun "$@"; }
fi

So I type bun dev and the server opens next to me instead of taking over my shell. bun install and hk check open a task pane that disappears when they pass.

When Claude Code runs the same commands, CLAUDECODE is set, and tests and installs run inline so the agent gets the exit code and the full output. Dev servers still go to a pane, because an agent waiting on a server that never exits is a stuck agent.

§Agents that know where they are

rex skill setup installs a skill and a session hook into Claude Code, Codex, OpenCode and Pi. When a Claude session starts, the hook tells it which Rex session and pane it's running in. The skill teaches it the rex command.

That changes what I can ask for. Claude can open a pane, run something in it, and read it back with rex capture, all without touching the pane I'm working in. When I built a TUI for Asana, the agent tested its own layouts with rex run --focus=false, rex send-key and rex capture --trim. It drove the app and checked the screen while I kept working.

The hook also asks Claude to name its session after the task on the first message, so my session list reads fix-projects-route and new-restaurant-reminders instead of a column of numbers. Claude reports its state back to Rex too, and the tab icon shows whether it's idle, working or waiting on me. With four agents running, that's the most useful pixel on the screen.

Rex can also resume them. If a pane with claude in it dies, Rex knows to bring it back with claude --resume <uuid>, and the same for Codex and OpenCode.

§A session per task

Put those together and the shape of my day has changed. A session used to be a project. Now it's closer to a task.

Because sessions are cheap to create from a script, I start most of them from somewhere else. Ctrl+B A opens my Asana tasks in their own tab, and Enter on a task starts a Claude session for it, or switches to the one already running. One task, one session, one agent. When it's done I kill the session and the task's context goes with it.

That tool turned out to be its own story, and it doesn't need Rex at all, so it got its own post.

§Rough edges

Rex is in beta and it shows in places.

  • Errors are honest but not helpful. "Name does not resolve" didn't hint at the tailnet mismatch.
  • Keys sent with rex send-key before a program's first render are lost.
  • Tab logos only exist for apps Rex knows. I can't give my Asana tab one.
  • I still haven't rebooted the Mini to prove the daemon comes back on its own.
  • My init.lua isn't in my dotfiles yet. It should be.

None of it has made me want to go back. tmux gave me sessions. Rex gives my agents sessions too, and that turns out to be the bigger deal.

g+

h homeb blogu usesa abouts somedayw nowq quotes