Zero-Friction Multi-Node tmux Session Handoff, Dynamic Viewport Resizing & SIGHUP-Safe Lifecycle Appliance (POSIX Shell & Zero-Pip Python 3)
Engineers and systems operators who move fluidly across multiple physical machines—a 4K workstation, a Linux laptop, a low-power netbook, and a mobile SSH terminal—hit four recurring operational bottlenecks with standard tmux workflows:
- Smallest-Screen Viewport Clamping ("The Dotted Border Problem"): Standard
tmux attachleaves previous SSH clients attached in the background. When you switch from a small laptop or mobile screen to a 4K desktop monitor,tmuxclamps your terminal dimensions to the smallest connected client. - Prefix-Matching Session Collisions: By default,
tmux has-session -t devandtmux attach -t devmatch prefixes, meaning an existingdev-sandboxsession will hijack commands intended fordev. - Nested Multiplexer Collisions (
$TMUXRecursion): Invoking a session launcher from inside an already-attachedtmuxpane spawns a broken nestedtmux-inside-tmuxsession instead of switching the client cleanly. - Self-Terminating Daemon / AI Agent
SIGHUPTruncation: When an automated workflow or CLI AI agent running inside atmuxsession attempts to close its own session on completion (tmux kill-session), it immediately sendsSIGHUPto its own PTY before flushing its final stdout response.
[Host A: Netbook 1024x600] ──(Auto-Detached)──┐
[Host B: Mobile SSH Client] ──(Auto-Detached)──┼──► [SnapTTY Engine] ──► Exact Match (-t "=session")
[Host C: 4K Workstation] ══(Atomic Snap-To)═╝ │
├── Outside $TMUX : attach-session -d + window-size latest
├── Inside $TMUX : switch-client -t "=session"
└── Self-Close : setsid Detached Reaper (--delay 3s)
-
Exclusive Atomic Takeover (
attach-session -d+window-size latest): Detaches stale/ghost SSH clients from previous computers in a single atomic operation and forces the PTY geometry to adapt immediately to your current display. -
Exact Target Matching (
-t "=session"): Eliminatestmuxprefix-matching ambiguity across all status, attach, switch, and teardown operations. -
Context-Aware
$TMUXRouting: Automatically detects if you are already insidetmuxand executestmux switch-client -t "=session"instead of nesting multiplexers. -
Single-Word Shortcut Linker (
snap link <alias> <cmd...>): Generates standalone executable wrappers in~/.local/bin/<alias>so typing a single word (e.g.,ai,dev,btop) upon SSH login immediately snaps you into that persistent workspace. -
Double-Forked
SIGHUP-Safe Reaper (snap close --delay N): Spawns an injection-proof,setsid-detached background timer (start_new_session=True, zeroshell=True) that waits$N$ seconds for the calling process to flush stdout before dissolving the session.
SnapTTY/
├── bin/
│ └── snap # Fast-path POSIX CLI wrapper (attach, link, list, status, close, reset, kill)
├── src/
│ └── snap_ctl.py # Zero-Pip Python 3 telemetry, exact-match router & setsid delayed reaper
├── conf/
│ └── tmux.snap.conf # Ergonomics profile (window-size latest, SGR-1006 mouse, 24-bit TrueColor)
├── tests/
│ └── test_snaptty.py # Deterministic unittest suite (prefix isolation, injection guard, reaper)
└── install.sh # Rootless installer to ~/.local/bin/snap and ~/.local/share/snaptty/
git clone https://github.com/Tethtibis/SnapTTY.git
cd SnapTTY
./install.shOn Computer 1, launch or snap into a persistent workspace:
snap devWalk over to Computer 2 (or connect from mobile SSH) and run the exact same command:
snap devComputer 1 is cleanly detached, Computer 2 takes over at full native screen resolution, and your cursor/process state is preserved without interruption.
Bind any CLI tool, TUI dashboard, or AI assistant to a single-word command in ~/.local/bin/:
# Create `~/.local/bin/monitor` that always snaps to a persistent btop session
snap link monitor btop
# Now from any SSH client, simply type:
monitorGenerated shortcuts also inherit lifecycle subcommands automatically:
monitor status # Inspect PID, window count, and attached client telemetry
monitor close --delay 3 # Arm SIGHUP-safe 3-second delayed session teardown
monitor reset # Kill and restart a fresh instanceEvery operation in snap_ctl.py supports --json for integration with system orchestrators and autonomous agents:
$ snap status --session dev --json
{
"timestamp": "2026-10-17T18:00:00.000000+00:00",
"origin": "workstation-node",
"module": "snaptty",
"action": "status",
"status": "SUCCESS",
"exit_code": 0,
"telemetry": {
"session_exists": true,
"session_name": "dev",
"attached_clients": 1,
"windows": 1,
"pane_pid": 41892,
"pane_command": "bash"
},
"diagnostics": {
"error_code": null,
"message": "Session 'dev' active with 1 client(s)."
}
}python3 -m unittest discover -s tests -vReleased under the MIT License. Engineered by Bill Fullen (@Tethtibis).