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 [partial]— with no argument, lists your tmux sessions (attached ones marked▸and sorted first, with window count and creation time). With an argument, attaches to the first session whose name containspartial(case-insensitive). Sotcd zerreattaches toZER-259-claude-579067.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.- Auto save/restore —
.tmux.confsets up tpm + resurrect + continuum so sessions (includingclaude/codexprocesses) survive reboots, and windows are named after their directory rather than the running process.
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 zer # attach/switch to the first session matching "zer"
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.zshThe test uses a private tmux server, so it never attaches to or closes your real sessions.
MIT