Skip to content

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.

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.

tmux is available in every major distribution’s package manager.

Debian / Ubuntu:

Terminal window
sudo apt update && sudo apt install tmux

Fedora / RHEL / CentOS:

Terminal window
sudo dnf install tmux

Arch Linux:

Terminal window
sudo pacman -S tmux

macOS (for Mac servers):

Terminal window
brew install tmux

Alpine Linux:

Terminal window
apk add tmux

Verify the install with tmux -V.

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:

Terminal window
tmux new-session -A -s main

This command:

  • Creates a new tmux session named main if one does not exist.
  • Attaches to the existing main session 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.

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.

All tmux commands start with the prefix key, which is Ctrl+B by default. Press Ctrl+B, release, then press the command key.

ActionKeys
New windowCtrl+B then c
Next windowCtrl+B then n
Previous windowCtrl+B then p
Split pane horizontallyCtrl+B then %
Split pane verticallyCtrl+B then "
Switch paneCtrl+B then arrow key
Detach (leave session running)Ctrl+B then d
List sessionstmux ls
Attach to sessiontmux attach -t main
Kill sessiontmux kill-session -t main
Scroll mode (copy mode)Ctrl+B then [
Exit scroll modeq
Rename windowCtrl+B then ,
Resize paneCtrl+B then Ctrl+arrow

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.

Place this in ~/.tmux.conf on your server for a mobile-friendly setup:

Terminal window
# Start window numbering at 1 (easier to reach on mobile keyboard)
set -g base-index 1
setw -g pane-base-index 1
# Increase scrollback buffer
set -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 terminal
set -g default-terminal "xterm-256color"
# Automatic window renaming
setw -g automatic-rename on

Enabling 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.

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.

“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:

Terminal window
set -g prefix C-a
unbind C-b
bind C-a send-prefix