mpmux by Mighty Painting
~/mpmux/docs ❯ less guide/sessions/contents ↓

3. Sessions that stay#

In this chapter you run shells in the background session host. Then you can close mpmux and come back to the same shells later, also from another device.

How it works#

A normal terminal stops its shell when you close the window. mpmux can run the shell in mpmux-sessiond, a small background service. The window only shows the session. If you close the window or lose the connection, the shell keeps running. When you open mpmux again, it attaches to the same session.

Start the session host#

On Linux the packages install a user service. Start it once:

systemctl --user enable --now mpmux-sessiond.service

On a Mac, mpmux-cli installs it as a launchd LaunchAgent, which starts the host when you log in and keeps it running when mpmux quits:

/Applications/mpmux.app/Contents/MacOS/mpmux-cli service install

(In a shell inside mpmux, plain mpmux-cli works.) The full macOS steps are in Installing mpmux.

By default the service listens only on a local socket. Nothing is reachable from the network, and no device can pair with it. To reach this machine from a phone or another computer, install the service with --remote instead; on Linux it takes the place of the packaged service:

mpmux-cli service install --remote --restart

--restart applies it to a service that already runs and ends that host's shells. Across machines has the whole setup.

Open a hosted session#

mpmux --sessiond-socket "$XDG_RUNTIME_DIR/mpmux-sessiond.sock" \
  --create-session --session-label shell

Now run a long command, close the window, and open the same session again. The command still runs.

▶ watch the clip

See your sessions#

mpmux-cli session --sessiond-socket "$XDG_RUNTIME_DIR/mpmux-sessiond.sock" list

The session manager gives the same view in a terminal interface:

mpmux-cli tui

Move a session to another device#

Only one device controls a session at a time. To continue on another device, choose Take Over on that device. The first device then shows the session as active elsewhere, until you take it back.

Chapter 5 shows how to pair a tablet or a phone. Chapter 8 shows how to reach a host on another machine.

When the connection drops#

If the network drops, mpmux reconnects by itself. The overview marks sessions that wait for a reconnect with an orange outline. Choose Reconnect in the card's pie menu to try again at once.

Next#

Chapter 4 shows all your sessions at once.