CLI tool
neurosnap/zmx avatar
neurosnap/zmx

zmx: terminal session persistence without windows, tabs or splits, and a ZMX_SESSION variable that can hijack your terminal

Session attach/detach for the terminal

2,304 stars189 forksZigMIT

At a glance

What is it?
zmx keeps shell sessions alive so you can detach and re-attach, share a session across clients and print its scrollback. It deliberately skips multiplexer features, supports only Mac and Linux, and does not support nested sessions.
Who is it for?
Choose zmx if tmux's windows, tabs and splits are more than you want and you only need sessions that survive a closed terminal on Mac or Linux. Skip it on Windows, or if you rely on splits.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly Zig, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 26, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • neurosnap/zmx2,304 ★ · +109
Star history
Repository2026-10-082026-11-26
neurosnap/zmx2.2k2.3k

109 Stars in the last 49 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

zmx does persistence and nothing else, so splits stay with your terminal emulator

zmx is a small Zig program that keeps a shell session running after you leave it. The feature list is short: persist terminal shell sessions, attach and detach without killing the shell, native terminal scrollback, multiple clients on one session, and restoring the previous terminal state and output when you re-attach.

The last line of that list is the boundary: the project does not provide windows, tabs or splits. If you work in one terminal and use your emulator's own tabs, that is the point. If your habit is a tmux layout with four panes, zmx gives you no replacement for it, and each pane would need its own named session started from your emulator.

The README links an essay titled You might not need tmux and two videos, an intro and an ai portal demo. Sponsorship is credited to pico.sh. The project works on Mac and Linux, and no Windows build is offered in the binaries list or elsewhere in the repository text.

Detach by closing the window, or with ctrl+backslash, and the key can collide with vim

The recommended way to detach is to close the terminal window. The alternatives are pressing `ctrl+\` or running `zmx detach`. The shortcut has a known clash: vim uses `ctrl+\ ctrl+n` to escape its own `:terminal`, so inside that terminal the zmx binding would fire first. Setting `ZMX_NO_DETACH_KEY` disables the shortcut, after which you rely on `zmx detach` or closing the window.

The usage text lists the main commands. `attach <name> [command...]` attaches and creates the session if needed. `run <name> [-d] [command...]` sends a command without attaching. `send <name> <text...>` sends raw input to the session PTY, and `print <name> <text...>` injects text into the session display. `write <name> <file_path>` writes stdin to a file through the session, and `detach` detaches all clients. Single letters in brackets, such as `a` and `r`, are shorthand. The usage block in the README text available here is cut off after detach, so run `zmx help` for the remaining commands.

ZMX_SESSION is inherited by every script, build tool and agent started inside a session

Nested sessions are not supported, and the mechanism explains why. Inside a session `ZMX_SESSION` is set, and `attach` reads it. Instead of creating another client, attach switches the calling terminal to the session you named.

That is a hazard when the variable is inherited rather than chosen. A script, build tool or coding agent started inside a session runs with `ZMX_SESSION` set, so `zmx attach other` from there moves the terminal somebody was using, and the session it was showing is left with no client. Nothing crashes. The person at the keyboard simply finds themselves in a different session.

The fix is to unset the variable for anything that attaches on its own behalf:

bash
env -u ZMX_SESSION zmx attach other

For non-interactive work, use `zmx run`, which never switches the caller. Anyone wiring zmx into automation should read this section first, since the default behavior is the surprising one.

Nothing in the prompt tells you that you are inside zmx

After attaching, zmx shows no indicator. What it provides is the `ZMX_SESSION` environment variable holding the session name, and the README suggests testing that variable in your prompt. For bash and zsh, the snippet goes in `.bashrc` or `.zshrc`:

bash
if [[ -n $ZMX_SESSION ]]; then
  export PS1="[$ZMX_SESSION] ${PS1}"
fi

There are variants for fish, powerlevel10k, oh-my-posh and Starship. The fish version wraps the original function by copying it to `_original_fish_prompt` and prepending the bracketed name. The Starship version uses an `env_var.ZMX_SESSION` block, and oh-my-posh checks `.Env.ZMX_SESSION` in a text segment.

Skipping this step has a real cost. With persistent sessions it is easy to type into the wrong shell, and the same variable that identifies the session is the one that triggers the attach-switch behavior above. Add the prompt marker before you trust the setup.

Five install routes, and four of them are not the project's own binary

The project publishes tarballs for v0.8.1 on zmx.sh: linux-aarch64, linux-x86_64, macos-aarch64 and macos-x86_64. Homebrew and mise are the quickest routes:

bash
brew install neurosnap/tap/zmx
bash
mise use zmx

Nix users can run it with no install via `nix run github:NixOS/nixpkgs/nixpkgs-unstable#zmx`, or build the main branch with `nix run github:neurosnap/zmx`. A flake.nix and flake.lock sit in the repository for that.

A further list of packages is marked unofficial: Alpine Linux (testing), two Arch AUR packages (one tracking releases, one tracking git), openSUSE Tumbleweed, a Gentoo overlay on Codeberg and an RPM packaging repository. Those are maintained by other people, so a version lag is a question for their maintainers and not for this project. Release dates give a sense of pace: v0.7.1 on 2026-08-27, v0.8.0 on 2026-09-04 and v0.8.1 on 2026-09-05.

Building from source asks for Zig v0.16 while the Dockerfile pins 0.17.0

The source route in the README is three steps: requires zig `v0.16`, clone the repo, run the build command. The command is:

bash
zig build -Doptimize=ReleaseSafe --prefix ~/.local

Add `~/.local/bin` to your PATH afterwards, since that is where the prefix puts the binary.

There is a discrepancy to check. The repository's Dockerfile sets `ARG ZIG_VERSION=0.17.0`, downloads that Zig for x86_64 or aarch64 and exits with an error on any other architecture. It installs curl, git, bats, coreutils and python3 on debian:12, which points at a test setup using bats. So the README names one Zig version and the container uses a newer one. If the build fails on v0.16, try the version in the Dockerfile.

Other files in the root, such as Dockerfile.release, Dockerfile.upload, brew.tmpl, gen-brew.sh and index.tmpl, are release tooling and need no attention from someone who only builds locally.

The Zig package exposes run and list, and create exists only with -Ddaemon=true

zmx can be embedded in another Zig program. The library in `src/lib.zig` is importable as the `zmx` package, and every function takes `(alloc, io, ...)` from `std.process.Init`. You add a dependency in build.zig.zon with a git URL pinned to a commit and a hash, wire it in build.zig with `b.dependency("zmx", ...)`, then call functions such as `zmx.run(gpa, io, "my-session", &.{"echo", "hi"}, .{})` and `zmx.list(gpa, io)`.

Two notes limit what you can assume. `zmx.run` creates the session and its daemon when absent, so you never call `zmx.create` first. And `zmx.create` is only available when the package is built with `-Ddaemon=true`, which is the default, so a build that turns the daemon off loses it.

Working programs are in the examples folder: list_sessions.zig and run_and_wait.zig, with an examples/README.md. The URL placeholder `<commit>` and hash `...` in the sample must be filled in by you, since the README gives no tagged version to copy.

Editorial conclusion

Choose zmx if tmux's windows, tabs and splits are more than you want and you only need sessions that survive a closed terminal on Mac or Linux. Skip it on Windows, or if you rely on splits. Before running agents or scripts inside it, check that anything which attaches on its own unsets ZMX_SESSION first, or it will pull your terminal into another session.

Frequently asked questions

What does zmx do?

zmx persists terminal shell sessions so you can detach and re-attach without killing the shell. Multiple clients can join one session, and re-attaching restores the earlier terminal state and output.

Does zmx replace tmux?

Only partly. zmx does not provide windows, tabs or splits, so it covers session persistence and nothing about layout.

Does zmx run on Windows?

No Windows build is listed. The project states that it works on Mac and Linux, and the release tarballs cover linux and macos on aarch64 and x86_64.

Official sources

  1. License: MIT
  2. neurosnap/zmx on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/neurosnap-zmx.svg)](https://hysenlabs.com/projects/neurosnap-zmx)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/neurosnap-zmx.svg)](https://hysenlabs.com/projects/neurosnap-zmx)

Was this useful?