Workflow 001: Remote Development
FreshUse tmux for persistent remote development sessions that survive disconnections.
When to Use
- Working on remote servers via SSH
- Need sessions to persist through network issues
- Running long processes (builds, deployments)
- Want IDE-like layouts in the terminal
Workflow Overview
Initial Setup
1. SSH to Server
bash
ssh user@server.example.com2. Start Named Session
bash
# Create or attach to session named "dev"
tmux new-session -A -s devThe -A flag
-A means "attach if exists, otherwise create" - perfect for reconnection!
3. Set Up Layout
Create an IDE-like development layout:
bash
# Start with editor pane
vim .
# Split right for terminal
Ctrl+b %
# In right pane, split bottom for logs
Ctrl+b "
# Navigate to bottom-right, run commands
cd logs && tail -f app.logResult:
+------------------+------------------+
| | |
| | Terminal |
| Editor | |
| +------------------+
| | |
| | Logs |
+------------------+------------------+Daily Workflow
Connect and Attach
bash
# One command to SSH and attach
ssh -t user@server "tmux new-session -A -s dev"Add to ~/.bashrc as alias:
bash
alias dev='ssh -t server "tmux new-session -A -s dev"'Detach When Done
bash
Ctrl+b d # Detach (session keeps running)Handle Disconnections
If your network drops, just reconnect:
bash
ssh user@server
tmux attach -t dev
# Everything is exactly as you left it!Advanced Setup
SSH Config for Quick Access
Add to ~/.ssh/config:
Host dev-server
HostName server.example.com
User username
RequestTTY yes
RemoteCommand tmux new-session -A -s devNow just:
bash
ssh dev-serverStartup Script for Complex Layouts
Create ~/dev-layout.sh on the server:
bash
#!/bin/bash
SESSION="dev"
# Kill existing session
tmux kill-session -t $SESSION 2>/dev/null
# Create session with editor window
tmux new-session -d -s $SESSION -n editor -c ~/project
# Split for terminal
tmux split-window -h -t $SESSION:editor -c ~/project
# Split for logs
tmux split-window -v -t $SESSION:editor.1 -c ~/project
# Create separate window for git
tmux new-window -t $SESSION -n git -c ~/project
# Create window for monitoring
tmux new-window -t $SESSION -n monitor -c ~/project
tmux send-keys -t $SESSION:monitor 'htop' C-m
# Set up main layout
tmux select-window -t $SESSION:editor
tmux select-pane -t $SESSION:editor.0
# Attach
tmux attach -t $SESSIONKeep-Alive Configuration
Prevent SSH timeouts in ~/.ssh/config:
Host *
ServerAliveInterval 60
ServerAliveCountMax 3Multi-Server Workflow
Use local tmux to manage connections to multiple servers:
bash
# Local machine
tmux new -s servers
# Split into panes
Ctrl+b % # Split
Ctrl+b " # Split again
# SSH to different servers in each pane
# Pane 0: ssh server1
# Pane 1: ssh server2
# Pane 2: ssh server3
# Synchronize if needed (same command to all)
:setw synchronize-panes onBest Practices
- Always use named sessions - Makes reconnection easy
- Use
new-session -A- Prevents duplicate sessions - Keep layouts simple - Complex setups are hard to restore
- Script complex setups - Reproducible environments
- Use SSH keys - Faster reconnection
Troubleshooting
Can't attach - session exists but is attached elsewhere
bash
# Force detach other clients
tmux attach -dt devSession disappeared after server reboot
Note
tmux sessions don't survive reboots. Use your setup script to recreate. Consider tools like tmux-resurrect for persistence.
Nested tmux (local + remote)
Change prefix on one of them:
bash
# On remote server ~/.tmux.conf
set -g prefix C-a
unbind C-b
bind C-a send-prefixNow:
Ctrl+bcontrols local tmuxCtrl+acontrols remote tmux