14.12.2025

zmx - saving terminal sessions in Linux and macOS

zmx is a lightweight tool for session persistence of terminal processes. It allows you to run processes in a terminal (shells, editors, builds, etc.), detach from them, and reconnect later without losing input/output or terminal state. Unlike tmux or screen, zmx does not provide windows, tabs, panes, or a window manager — only attach/detach functionality and terminal state restoration.
zmx.sh

What zmx is used for

Main purposes:

How it differs from tmux:

Installation

Prebuilt binaries

Download the archive for your platform:

  1. Linux (x86_64 / aarch64)
  2. macOS (x86_64 / aarch64)

Repository links: https://github.com/neurosnap/zmx

Via Homebrew (macOS / Linux)

brew tap neurosnap/tap
brew install zmx

Building from source

Requires Zig (v0.15):

git clone https://github.com/neurosnap/zmx
cd zmx
zig build -Doptimize=ReleaseSafe --prefix ~/.local # make sure ~/.local/bin is in your PATH

Quick start — command and output

After installation, the following command is available:

zmx <command> [args]

Main commands

Command Description
zmx attach <name> Creates a new session with the specified name or attaches to an existing one
zmx attach <name> <command> Attaches to a session and runs the specified command inside it
zmx detach
Ctrl + \
Detaches the current terminal from the session without stopping running processes
zmx list Displays a list of all active zmx sessions
zmx kill <name> Forcefully terminates the specified session
zmx help Shows help for available commands
zmx version Displays the installed zmx version

Shell configuration

To see that you are inside a zmx session, you can add the session name to your prompt:

fish:

functions -c fish_prompt _original_fish_prompt
function fish_prompt
if set -q ZMX_SESSION
echo -n "[$ZMX_SESSION] "
end
_original_fish_prompt
end

zsh:

BASE_PROMPT=$PS1
PROMPT="${ZMX_SESSION:+[$ZMX_SESSION]} $BASE_PROMPT"

Using zmx with SSH

zmx works well over SSH: you can set a RemoteCommand so that you automatically attach to the appropriate session upon connection. For example:

Host dev.*
RemoteCommand zmx attach %k
RequestTTY yes

This is useful if you use many terminals on the same remote machine.

FAQ

Conclusion

zmx is a convenient tool for developers who want to preserve terminal sessions between reconnects without introducing the complexity of full-featured terminal multiplexers. It allows you to keep long-running processes alive while continuing to use your terminal emulator and window manager exactly as you prefer, instead of replacing them with an additional layer of window and pane management.

In practice, zmx works especially well for long-running builds, test suites, and data processing tasks, where accidental terminal closure or SSH disconnects would otherwise interrupt work. When used over SSH, it can significantly simplify remote workflows by automatically reattaching to the same session after reconnecting. Running editors such as Vim or Neovim inside a zmx session helps avoid losing context or progress due to network issues, while organizing sessions by project name keeps your workflow predictable and easy to manage.

Overall, zmx is a strong choice for workflows that require reliable session persistence but do not benefit from the overhead of traditional terminal multiplexers, making it ideal for users who value simplicity, stability, and control.