tmux Workflow with ZestSSH
Mobile SSH connections drop. Wi-Fi hands off, cellular towers switch, iOS suspends background apps. When a raw SSH session dies, any running process dies with it. tmux solves this by keeping your session alive on the server, ready to reattach when you reconnect.
Why tmux Matters for Mobile
Section titled “Why tmux Matters for Mobile”ZestSSH already supports keep-alive packets to reduce idle disconnects, but network interruptions are unavoidable on mobile. tmux (or screen) runs server-side, so:
- A dropped connection does not kill your running processes.
- You can reconnect from a different device and pick up where you left off.
- You can run a long build or deployment, lock your phone, and check results later.
Installing tmux on Your Server
Section titled “Installing tmux on Your Server”tmux is available in every major distribution’s package manager.
Debian / Ubuntu:
sudo apt update && sudo apt install tmuxFedora / RHEL / CentOS:
sudo dnf install tmuxArch Linux:
sudo pacman -S tmuxmacOS (for Mac servers):
brew install tmuxAlpine Linux:
apk add tmuxVerify the install with tmux -V.
Per-Connection Auto-Attach
Section titled “Per-Connection Auto-Attach”The most powerful pattern is to have ZestSSH automatically attach to a tmux session every time you connect to a server. In the connection editor, set the Startup Command to:
tmux new-session -A -s mainThis command:
- Creates a new tmux session named
mainif one does not exist. - Attaches to the existing
mainsession if it is already running.
Every time you tap Connect in ZestSSH, you land in your persistent tmux session. If the connection dropped while a build was running, you reconnect and see the output waiting for you.
Named Sessions Per Purpose
Section titled “Named Sessions Per Purpose”For servers where you do different kinds of work, use different session names per ZestSSH connection. Create two connections to the same host:
- “Prod - Logs” with startup command
tmux new-session -A -s logs - “Prod - Deploy” with startup command
tmux new-session -A -s deploy
Each connection drops you into a purpose-specific tmux session.
Essential tmux Commands
Section titled “Essential tmux Commands”All tmux commands start with the prefix key, which is Ctrl+B by default. Press Ctrl+B, release, then press the command key.
| Action | Keys |
|---|---|
| New window | Ctrl+B then c |
| Next window | Ctrl+B then n |
| Previous window | Ctrl+B then p |
| Split pane horizontally | Ctrl+B then % |
| Split pane vertically | Ctrl+B then " |
| Switch pane | Ctrl+B then arrow key |
| Detach (leave session running) | Ctrl+B then d |
| List sessions | tmux ls |
| Attach to session | tmux attach -t main |
| Kill session | tmux kill-session -t main |
| Scroll mode (copy mode) | Ctrl+B then [ |
| Exit scroll mode | q |
| Rename window | Ctrl+B then , |
| Resize pane | Ctrl+B then Ctrl+arrow |
Working with ZestSSH’s Touch Gestures
Section titled “Working with ZestSSH’s Touch Gestures”ZestSSH has built-in gestures that complement tmux:
- Two-finger tap sends
Ctrl+C--- useful for cancelling commands inside a tmux pane. - Three-finger tap pastes from clipboard --- for pasting commands into tmux.
- Two-finger horizontal swipe switches between ZestSSH sessions --- useful when you have multiple server connections open alongside tmux windows.
Recommended tmux Configuration
Section titled “Recommended tmux Configuration”Place this in ~/.tmux.conf on your server for a mobile-friendly setup:
# Start window numbering at 1 (easier to reach on mobile keyboard)set -g base-index 1setw -g pane-base-index 1
# Increase scrollback bufferset -g history-limit 50000
# Enable mouse support (works with ZestSSH's touch input)set -g mouse on
# Reduce escape delay (responsive on slow connections)set -sg escape-time 10
# 256-color terminalset -g default-terminal "xterm-256color"
# Automatic window renamingsetw -g automatic-rename onEnabling mouse on lets you tap tmux panes to switch between them and scroll the buffer with swipe gestures, which works well with ZestSSH’s terminal emulator.
tmux vs Mosh
Section titled “tmux vs Mosh”ZestSSH also supports Mosh on desktop platforms (Windows via WSL, macOS, and Linux). Mosh handles network roaming at the protocol level --- it uses UDP instead of TCP, so the connection survives IP changes without any server-side session manager.
However, tmux and Mosh solve different problems and work well together:
- Mosh keeps the connection alive across network changes.
- tmux keeps the session alive when the connection truly ends (device off, app killed, Mosh server restarted).
The recommended setup for maximum resilience: connect with Mosh (where available), and auto-attach to tmux as the startup command. This gives you both transport-layer and session-layer persistence.
On mobile (Android/iOS), Mosh is not yet available, so tmux is your primary defense against disconnects. Enable SSH keep-alive (set Keep-Alive Interval to 15-30 seconds in the connection editor) to minimize idle drops, and rely on tmux for recovery when they happen.
Troubleshooting
Section titled “Troubleshooting”“sessions should be nested” warning: This happens when you try to start tmux inside an existing tmux session. The tmux new-session -A -s main startup command handles this correctly by attaching instead of nesting.
Garbled display after reconnect: If your terminal looks wrong after reattaching, press Ctrl+B then : and type refresh-client. You can also resize the ZestSSH terminal (rotate your device or adjust the font size) to force a redraw.
Key prefix conflicts: If Ctrl+B conflicts with your shell or editor, remap it in ~/.tmux.conf:
set -g prefix C-aunbind C-bbind C-a send-prefix