I started using tmux about a year ago and honestly can’t imagine going back. If you spend a lot of time in the terminal like I do, tmux is a game-changer.
Why I Use tmux
I used to have like 10 terminal windows open, constantly switching between them. SSH sessions would die when my laptop went to sleep. I’d lose my carefully arranged split panes when I closed a terminal by accident.
tmux solved all of that. Now I have persistent sessions that survive disconnects, I can split my terminal however I want, and everything stays exactly how I left it.
Getting Started
Install it with Homebrew:
| |
That’s it. Run tmux and you’re in.
The Basics (What I Actually Use Daily)
tmux uses a “prefix key” for commands - by default it’s Ctrl-b. You press that first, release, then press the command key.
Sessions - The Killer Feature
This is why tmux is worth it:
| |
I have persistent sessions for different projects. My work session, my personal projects session, experiments session. They’re always running, I just attach/detach as needed.
Window Management
Think of these like browser tabs:
| |
I typically have 3-4 windows per session: one for code, one for servers, one for git operations, one for random commands.
Note on split screens: I use iTerm’s built-in split panes instead of tmux panes. iTerm handles splits well, and it’s one less thing to manage in tmux.
My ~/.tmux.conf
I spent way too long tweaking this, but here’s what actually matters:
| |
Put that in ~/.tmux.conf and reload with Ctrl-b : then source-file ~/.tmux.conf.
My Actual Workflow
Starting my day:
| |
Everything’s exactly where I left it yesterday. Editor still open, servers still running, git still on the right branch.
Working on a side project:
| |
Context switch in 2 seconds.
SSH-ing to a server:
| |
My remote session persists even if my connection drops. I can pick up right where I left off.
What Took Me a While to Learn
Copy mode: Ctrl-b [ lets you scroll back and copy text. Use arrow keys to navigate, Space to start selection, Enter to copy, then Ctrl-b ] to paste. Took me forever to figure this out.
Detaching vs Closing: Ctrl-b d detaches (session keeps running). exit in all windows actually closes the session. I used to confuse these.
Command mode: Ctrl-b : opens a command prompt. You can type any tmux command here. I use it for killing sessions: :kill-session -t oldproject
Session groups (viewing different windows simultaneously): This took me forever to figure out. When you attach to the same session from multiple terminals using tmux attach, all terminals mirror each other - they show the same window. Not what you want.
If you want independent views of different windows within the same session, use session groups:
| |
What this does:
- All sessions share the same windows (0, 1, 2, 3, etc.)
- Each terminal can view a different window independently
- Changes in one terminal (creating/closing windows) appear in all
- But each terminal can switch windows independently!
Verify it’s working:
| |
The (group work) indicates they share the same windows.
What NOT to do:
| |
Bonus alias (add to ~/.zshrc or ~/.bashrc):
| |
This was a game-changer for me - I can have my code editor in one terminal window, logs in another, and tests in a third, all from the same tmux session but viewing different windows at the same time.
Quick Reference (What I Look Up Every Time)
| What I Want | Key |
|---|---|
| Detach from session | Ctrl-b d |
| New window | Ctrl-b c |
| Next/prev window | Ctrl-b n/p |
| Copy mode (scroll) | Ctrl-b [ |
| List all commands | Ctrl-b ? |
Is It Worth Learning?
If you live in the terminal: absolutely yes.
The learning curve is real - for the first few days I kept closing tmux by accident and getting confused. But once it clicks, you’ll wonder how you worked without it.
Start simple: just use sessions and detach/attach. That alone is worth it. Then gradually add windows and panes as you get comfortable.
For me, tmux means I can close my laptop, open it somewhere else, and continue exactly where I left off. That’s powerful.
Resources
- tmux cheat sheet - I still reference this
- Official docs: https://github.com/tmux/tmux/wiki
- Book: “tmux 2” by Brian Hogan - actually worth reading
That’s my tmux setup. Not fancy, but works great for me. If you have questions or want to share your setup, find me on X.