Tools: tmux: Persistent Terminal Sessions for Developers (2026)

Tools: tmux: Persistent Terminal Sessions for Developers (2026)

Install

Core concepts

Start and attach to sessions

Windows

Scrollback and copy mode

Auto-start a session on login

~/.tmux.conf I lost three hours of work to a dropped SSH connection before I learned about tmux. One detached session later and that problem stopped existing entirely. If you spend any meaningful time on remote servers, tmux is the single highest-leverage tool you can add to your workflow. Two things make it worth learning: sessions survive after you close your terminal or lose an SSH connection — your processes keep running and you reconnect to find everything exactly where you left it. And you can split a single terminal into multiple panes and windows without juggling tabs. tmux has three levels: The prefix key is how you send commands to tmux without the keystrokes going to the program running inside it. The default is Ctrl+B. Press it, release, then press the command key. Create a new named session: Detach (session keeps running in the background): Short form: tmux a -t myproject. With only one session, tmux a is enough. Windows appear in the status bar at the bottom. The active one has a * next to its name. Zoom is one of the most useful shortcuts — it temporarily expands a pane to fill the entire window without closing the others. Hit it again to return to the split view. Mouse scroll does not work inside tmux by default. To scroll: This enters copy mode. Arrow keys and Page Up/Page Down navigate. Press / to search, n for the next match, q to exit. tmux sessions do not survive a reboot. For development machines where you always want a session waiting: The [ -z "$TMUX" ] guard prevents tmux from launching inside an existing tmux session, which would nest them. A minimal config that most people find immediately useful: Reload the config without restarting: Mouse support is the single option worth enabling immediately if you are used to a GUI terminal. It makes pane navigation and resizing click-based while you build up the keyboard shortcuts. Found this useful? SysEmperor has more Linux tutorials and free developer tools — including a Cron Visual Editor, fstab Editor, and a growing library of downloadable AI skills at sysemperor.com. Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

# Debian / Ubuntu -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install tmux # RHEL / Fedora / Rocky -weight: 600;">sudo -weight: 500;">dnf -weight: 500;">install tmux # macOS -weight: 500;">brew -weight: 500;">install tmux # Debian / Ubuntu -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install tmux # RHEL / Fedora / Rocky -weight: 600;">sudo -weight: 500;">dnf -weight: 500;">install tmux # macOS -weight: 500;">brew -weight: 500;">install tmux # Debian / Ubuntu -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install tmux # RHEL / Fedora / Rocky -weight: 600;">sudo -weight: 500;">dnf -weight: 500;">install tmux # macOS -weight: 500;">brew -weight: 500;">install tmux tmux new -s myproject tmux new -s myproject tmux new -s myproject tmux attach -t myproject tmux attach -t myproject tmux attach -t myproject tmux kill-session -t myproject tmux kill-session -t myproject tmux kill-session -t myproject # add to ~/.bashrc or ~/.zshrc if [ -z "$TMUX" ]; then tmux attach -t main 2>/dev/null || tmux new -s main fi # add to ~/.bashrc or ~/.zshrc if [ -z "$TMUX" ]; then tmux attach -t main 2>/dev/null || tmux new -s main fi # add to ~/.bashrc or ~/.zshrc if [ -z "$TMUX" ]; then tmux attach -t main 2>/dev/null || tmux new -s main fi # Start window and pane numbering at 1 instead of 0 set -g base-index 1 setw -g pane-base-index 1 # Enable mouse: click to focus panes, drag to resize set -g mouse on # Increase scrollback set -g history-limit 10000 # Status bar: show session name on the left, time on the right set -g -weight: 500;">status-left "[#S] " set -g -weight: 500;">status-right "%H:%M" # Start window and pane numbering at 1 instead of 0 set -g base-index 1 setw -g pane-base-index 1 # Enable mouse: click to focus panes, drag to resize set -g mouse on # Increase scrollback set -g history-limit 10000 # Status bar: show session name on the left, time on the right set -g -weight: 500;">status-left "[#S] " set -g -weight: 500;">status-right "%H:%M" # Start window and pane numbering at 1 instead of 0 set -g base-index 1 setw -g pane-base-index 1 # Enable mouse: click to focus panes, drag to resize set -g mouse on # Increase scrollback set -g history-limit 10000 # Status bar: show session name on the left, time on the right set -g -weight: 500;">status-left "[#S] " set -g -weight: 500;">status-right "%H:%M" Ctrl+B :source-file ~/.tmux.conf Ctrl+B :source-file ~/.tmux.conf Ctrl+B :source-file ~/.tmux.conf - Session — a collection of windows. One session per project is the natural fit. - Window — a full-screen view inside a session. Think of it like a browser tab. - Pane — a split region within a window. One window can hold several panes.