Operations 9 min read

Boost Your Productivity: Master tmux Basics in 10 Minutes

This guide introduces tmux, a terminal multiplexer, explaining how to create, detach, and reattach sessions, manage windows, panes, and shortcuts, and provides installation steps and useful aliases, enabling developers to maintain persistent work environments and boost command‑line productivity.

Radish, Keep Going!
Radish, Keep Going!
Radish, Keep Going!
Boost Your Productivity: Master tmux Basics in 10 Minutes
tmux is a terminal multiplexer that lets you create, access, and control multiple terminals from a single screen. It can detach and continue running in the background, then reattach.

When I first saw tmux I didn't feel much, but after using the terminal more and encountering issues, I revisited tmux and it changed my workflow.

This article will spend ten minutes introducing tmux's basic use cases.

Featured image of post Mac: tmux best practices
Featured image of post Mac: tmux best practices

What is a Terminal Session

Recall your typical workflow: open an iTerm2 window, ssh to a remote machine, navigate to a directory, work, then close the iTerm2 window. That sequence is a terminal session whose lifecycle is tied to the terminal window. When the window closes, the session ends. tmux lets you detach the session from the terminal so you can resume later without repeating the steps.

Let's see how tmux achieves this.

In this demonstration:

Run tmux new -s test to create a tmux session and open a directory.

Detach the session and return to iTerm2.

Run tmux attach-session to reattach, restoring the previous state.

This is the basic use of tmux: detaching a session while preserving its state.

TL;DR

It allows multiple sessions in a single window, useful for running several command-line programs simultaneously. It lets new windows join an existing session. Each session can have multiple attached windows, enabling real-time sharing. It supports arbitrary vertical and horizontal pane splitting.

Tmux Basic Usage

Install Tmux

On macOS, install tmux with Homebrew: brew install tmux For other environments, see the official installation guide.

Start and Exit Tmux

After installation, start a tmux session by typing tmux in the terminal. Type exit to leave the session and return to the original terminal.

ITerm2 2
ITerm2 2

Prefix Key

All tmux shortcuts start with the prefix ⌃b (Control‑b on macOS). Press ⌃b ? to list all shortcuts. Shortcuts are grouped into window management, pane management, and session management.

Session Management

Running tmux multiple times creates multiple sessions. Use the prefix ⌃b with the following keys: ⌃b + $ – rename the current session. ⌃b + s – list sessions. ⌃b + d – detach the current session. tmux new -s foo – create a session named foo. tmux ls – list all sessions. tmux a – attach to the most recent session. tmux a -t foo – attach to session foo. tmux kill-session -t foo – delete session foo. tmux kill-server – delete all sessions.

alias tnew='tmux new -s' # create a session
alias tls='tmux ls'
alias td='tmux detach' # detach session, preserving state
alias ta='tmux attach -t' # attach session
alias tkss='tmux kill-session -t'

Pane Management

Tmux can split a window into multiple panes. Common shortcuts: ⌃b + % – split vertically. ⌃b + " – split horizontally. ⌃b + x – close the current pane. ⌃b + { – move pane left. ⌃b + } – move pane right. ⌃b + ; – select the last used pane. ⌃b + o – select the next pane (or use arrow keys). ⌃b + space – cycle pane layouts (use ⌥1‑⌥5 to choose specific layout). ⌃b + z – toggle pane zoom. ⌃b + q – show pane numbers for quick selection.

Window Management

When panes become crowded, you can create additional windows. Common shortcuts: ⌃b + c – create a new window. ⌃b + p – go to the previous window. ⌃b + n – go to the next window. ⌃b + w – list windows (use ⌃p / ⌃n to navigate on macOS). ⌃b + & – close the current window. ⌃b + , – rename the window (Chinese characters are supported). ⌃b + 0‑9 – switch to window number. ⌃b + f – search windows by name with fuzzy matching.

Conclusion

This article covered tmux's basic usage and shortcuts. Many advanced scenarios, such as integrating tmux with Vim for more efficient coding, were not covered. Readers are encouraged to try tmux and boost their productivity.

References

[1] Installing tmux: https://github.com/tmux/tmux/wiki/Installing

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

productivityCommand LineSession Managementterminaltmuxpane
Radish, Keep Going!
Written by

Radish, Keep Going!

Personal sharing

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.