The map
December 04, 2026
At the end, you can point at any part of your Rex screen, say its Rex name, and reach it from the command line.
Why this comes first
In tmux you write -t session:window.pane to say what a command acts on. Rex has the same need. Each rex command and each Lua call in this course acts on a target. This lesson gives you the names of the parts and the rules for a target. The lessons after it use both.
One program in place of two
Today three programs do your terminal work. Ghostty draws the terminal. tmux keeps your programs running and splits the screen. smug builds a tmux session from a YAML file.
Rex is a terminal with two parts: an app, built on the libghostty core, and a multiplexer (What's Rex). The multiplexer is the Rex server. It runs your shells and the programs in them, and it keeps them running when no app is connected. Rex for Mac runs a server for you. The app is a client of that server. The rex command is a client too.
| Job | Today | In Rex |
|---|---|---|
| Draw the terminal | Ghostty | The Rex app |
| Keep programs running, split the screen | The tmux server | The Rex server |
| Change things from a script | tmux commands | The rex command, and Lua |
| Build the windows of a project | smug and a YAML file | Lua (lessons 4 to 8) |
| Your keys | tmux.conf | ~/.config/rex/init.lua (lesson 3) |
Three levels
Rex groups your work on three levels (What's Rex). You know all three from tmux.
| Rex name | What it is | tmux name | In a smug file |
|---|---|---|---|
| Session | A group of related work, such as one project. It runs if you look at it or not. | Session | session: |
| Window | A tab in a session. It holds a layout of blocks. | Window | An item under windows: |
| Block | A pane in a window. Today each block is a terminal. | Pane | An item under panes: |
Rex has two words for the second and third level. Commands and Lua say window and block. The app says tab and pane. In this course, a command or a field name uses the first pair, and a sentence about what you see uses the second pair.
Here is the session that your v4.yml makes, drawn with the Rex names.
session: i4o-v4
window 1: code
window 2: agents
IDs, labels and targets
Each session, window and block has an ID that does not change. Each can also have a label that you choose. A target is the text that you give a command to say which one you mean. Rex tries to match a target in this order and stops at the first kind that matches (The CLI, targets):
- The full ID, for example
session:01a10cf3-2655-7e48-9b9c-43dd6612bef5. - A label. Upper case and lower case are the same.
- A position, counted from 1. For a window, the position is its place in the tab order.
- A short ID: the end of an ID, four characters or more.
Three options carry a target: -s for a session, -w for a window, -b for a block. With none of them, a command acts on the terminal that you typed it in, and on that terminal's session.
If a target matches two things, the command changes nothing, lists the matches, and exits with status 3. Two things can have the same label, and a label can change. So a label is good for work at the keyboard, and an ID is the safe choice in a script.
Do it
Find the rex command
Open Rex. In a pane, run:
which rex echo "$REX_BIN_DIR"Rex puts
REX_BIN_DIRat the front ofPATHin each terminal that it opens. Your shell start-up files run after that and can put other directories in front. Ifwhich rexprints nothing, add this to~/.zshrcand open a new pane (The CLI, PATH set-up):if [ -n "$REX_BIN_DIR" ]; then export PATH="$REX_BIN_DIR:$PATH" fiMake a session to practise in
Press Cmd+N for a new session (Mac Actions). Do the next steps there, so that the labels of your real work stay as they are.
Look at what is there
rex ls rex session inspect rex block inspect echo "$REX_BLOCK"rex lslists your sessions. The twoinspectcommands show the session and the block that you are in.REX_BLOCKholds the ID of the terminal's own block. Find that ID in the output ofrex block inspect.Make a second window and a second pane
Press Cmd+T for a new tab. Press Cmd+D to split the pane to the right (Mac Actions). Then run:
rex window ls rex block lsCount the lines. They must agree with what you see.
Give labels
rex session rename scratch rex window rename notes rex block rename leftEach command acts on the session, window or block that you typed it in. Run
rex lsandrex block lsagain and find the labels.Reach a pane by its label
Move to the other pane (Cmd+]). From there, type into the pane with the label
left, and read its screen:rex send -b left 'echo hello from the other pane' rex send-key -b left enter rex capture -b left --trimrex sendtypes the text and does not press Enter.rex send-keypresses a key.rex captureprints the screen of a block (Shell Scripting).Predict, then test
In the pane
left, starttop. Before you do the next part, write down your answer: if you quit the Rex app now, doestopstop?Quit the app with Cmd+Q. Open it again. Look at the pane.
Check yourself
From memory
Look at your Rex window. Write its parts as a tree: the session, each window in it, each block in each window. Use the labels that you gave.
Check yourself
Answer from memory. Do not scroll up first.
Which part of Rex keeps your programs running when the app is closed?
In which order does Rex try to match a target?
Two blocks have the label logs. You run rex send -b logs hello. What happens?
What does tmux call the thing that Rex calls a block?
0 of 4 answered
Primary source
Short. Read the two sections "The Server and the Apps" and "Sessions, Windows and Blocks". Then keep the glossary and the tmux and smug map open for the next lessons.
Stuck, or curious?
Ask Claude. Paste the output or the error and say what you expected. A follow-up question is part of the lesson, and it tells Claude what to teach next.