This is the follow-up to tmux Cheat Sheet for Remote Work.
Once you are comfortable starting, detaching, and reattaching sessions, tmux becomes useful for more than just keeping a process alive.
This follow-up covers the features that make tmux effective for day-to-day development, operations work, and debugging on remote hosts.
Build a Useful Layout Quickly
A common working layout is one pane for the app, one for logs, and one for ad hoc commands.
tmux new -s deploy
Then use these keys:
- Create a new window:
Ctrl-b c - Split the current pane left/right:
Ctrl-b % - Split the current pane top/bottom:
Ctrl-b " - Move to the next pane:
Ctrl-b o - Swap panes:
Ctrl-b {andCtrl-b } - Zoom the active pane temporarily:
Ctrl-b z
This is useful when you want to tail logs in one pane while running deploy or diagnostic commands in another.
Create a Preset Layout
Once you find a layout that works, stop rebuilding it by hand.
You can script tmux to create a repeatable session with named panes and commands already running:
#!/usr/bin/env bash
SESSION="deploy"
tmux has-session -t "$SESSION" 2>/dev/null || {
tmux new-session -d -s "$SESSION" -n app
tmux send-keys -t "$SESSION":0.0 "vim" C-m
tmux split-window -h -t "$SESSION":0
tmux send-keys -t "$SESSION":0.1 "npm run deploy" C-m
tmux split-window -v -t "$SESSION":0.1
tmux send-keys -t "$SESSION":0.2 "tail -f /var/log/app.log" C-m
tmux select-layout -t "$SESSION":0 tiled
}
tmux attach -t "$SESSION"
This pattern does two useful things:
- It reuses the session if it already exists instead of creating duplicates.
- It creates the session in the background with
-d, builds the layout, and only then attaches you to it.
If you use tmux every day, keeping a script like this in ~/bin/ or alongside your project is usually faster than rebuilding the same three-pane view every time.
Rename Things Early
Sessions and windows become hard to navigate if everything keeps the default names.
- Rename a session:
tmux rename-session -t deploy api-deploy - Rename the current window:
Ctrl-b , - List windows in the session:
Ctrl-b w
Good names matter most when you reconnect later or keep several sessions open at once.
Use Copy Mode Instead of Losing Scrollback
tmux copy mode is the safest way to inspect old output on a remote host.
- Enter copy mode:
Ctrl-b [ - Move with arrow keys or Page Up / Page Down
- Search forward:
/ - Search backward:
? - Exit copy mode:
q
This is more reliable than depending on the terminal application’s local scrollback, especially after reconnecting over SSH.
Send the Same Input to Multiple Panes
Synchronised panes are useful when you need to run the same command in parallel across similar shells.
tmux set-window-option synchronize-panes on
Turn it off again as soon as you are done:
tmux set-window-option synchronize-panes off
This is helpful for coordinated tasks such as comparing services, but it is also an easy way to make the same mistake twice. Use it carefully.
Share a Session for Pair Debugging
tmux can also support collaborative troubleshooting on the same machine. If two people can log into the same host and access the same tmux session, they can inspect the same panes and commands.
A simple pattern is:
tmux new -s incident
tmux attach -t incident
That makes it easier to walk through logs, rerun commands, and keep a shared view of the debugging session.
Verification
Use these commands to check the current state:
tmux ls
tmux list-windows
tmux list-panes
They give you a quick inventory of what is running before you detach or clean up.
Tradeoffs
- tmux has a steep initial learning curve because most commands are behind a prefix key.
- Shared sessions are powerful, but they rely on shell access and local permissions.
- Advanced layouts help once you use tmux regularly, but they add overhead if you only need one shell.
Summary
The advanced value of tmux is not in memorising dozens of commands. It is in combining a few of them to keep context visible: one session, a clear layout, reliable scrollback, and a repeatable way to reconnect.