Small zsh + tmux setup that makes long-running AI CLI sessions (Claude Code, Codex, etc.) easy to launch, find, and reattach to — including from your phone.
The name comes from tcd ("tmux cd"): jump to a tmux session by typing part of
its name instead of the full thing.
tcd [row|partial]— lists compact numbered rows with attachment, agent state, and age. Use a row number or name fragment to attach. Exact names win over partial matches, andtcd -returns to the previous session.- Phone-first launch commands —
tcd cl [project]andtcd co [project]start or attach Claude and Codex. Projects can be paths or short folder-name matches under configured project roots. - Remote Macs —
tcd @host [command]runs the same command through SSH.tcd hostsshows configured hosts and whether they answer. tcd close [partial]— the mirror image of attaching: kill sessions by partial name instead of memorizing the full one.tcd close(no argument) closes the session you're currently in;tcd close zercloses every session matchingzer(handy for clearing out a project's agents at once);tcd close allcloses everything. Closing kills the session's processes, so it lists what it's about to kill and asks for a one-keyy/Nconfirmation — pass-y(or-f) to skip it.kill,rm, andxwork as aliases forclose.- Auto-named sessions —
claudeandcodexare wrapped so that when you run them outside tmux they launch inside a tmux session named after the current project (<repo>-<program>-<hash>). The path hash keeps same-named repos in different folders from colliding. Run them inside tmux and they behave normally. --yoloshorthand —claude --yoloexpands toclaude --dangerously-skip-permissions.- Session snapshots —
.tmux.confsets up tpm + resurrect + continuum to save layouts every five minutes. Automatic restore is off. Running processes do not survive a lost tmux server. - Install checks —
tcd doctorreports missing tools, shell setup, project roots, remote hosts, and local session count.
Running agents in named tmux sessions means you can close your laptop, reconnect
later (or SSH in from a phone) and pick the session back up with a short tcd
command instead of memorizing generated session names.
- zsh —
tcd.zshuses zsh-only syntax (${(q)...},${var:t}); it will not work in bash. - tmux
git,grep,sort,column(standard on macOS/Linux).claude/codexCLIs are optional — their wrappers only activate if the CLI is installed.
git clone https://github.com/mchen04/tcd ~/tcd
cd ~/tcd
./install.shThe installer will:
- Append
source ~/tcd/tcd.zshto your~/.zshrc(idempotent). - Symlink
~/.tmux.confto this repo's copy (backing up any existing file). - Clone tpm if it's missing.
Then restart your shell, start tmux, and press prefix + I (capital i) once to
install the tmux plugins.
If you'd rather not run the script, just add this to your ~/.zshrc:
source /path/to/tcd/tcd.zshand merge .tmux.conf into your own.
tcd # list all sessions
tcd 2 # attach to row 2
tcd zer # attach/switch to the first session matching "zer"
tcd - # return to the previous session
tcd cl pancake # start or attach Claude in the Pancake project
tcd co pancake # start or attach Codex in the Pancake project
tcd @mbp # list sessions on a configured remote Mac
tcd doctor # check the local setup
tcd close # close the session you're in right now
tcd close zer # close every session matching "zer" (asks to confirm)
tcd close -y zer # ...same, but skip the confirmation prompt
tcd close all # close every session
claude # outside tmux: opens a named session for this project
claude --yolo # = claude --dangerously-skip-permissionszsh tests/smoke.zshTests must use the private socket helper in tests/lib.zsh. They must never run
an unsocketed destructive tmux command. The benchmark covers read-only list and
match performance; it does not close sessions.
MIT