How I Use tmux on Mac

My tmux workflow and setup on Mac - why I switched and how it changed the way I work

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:

1
brew install tmux

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Start a named session
tmux new -s myproject

# Detach (close terminal, session keeps running)
Ctrl-b d

# Come back later, everything's still there
tmux attach -t myproject

# List all your sessions
tmux ls

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# New window
Ctrl-b c

# Next/previous window
Ctrl-b n / Ctrl-b p

# Jump to window 0-9
Ctrl-b 0-9

# Rename window (I do this for every window)
Ctrl-b ,

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Mouse support
set -g mouse on

# Start window numbering at 1 (easier to reach than 0)
set -g base-index 1

# More scrollback history
set -g history-limit 10000

# Better colors
set -g default-terminal "screen-256color"

# Reload config quickly
bind r source-file ~/.tmux.conf \; display "Config reloaded!"

# Don't auto-rename my carefully named windows
set-option -g allow-rename off

# Simple status bar
set -g status-style bg=black,fg=white
set -g status-left '#[fg=green]#S '
set -g status-right '#[fg=cyan]%d %b %R'

Put that in ~/.tmux.conf and reload with Ctrl-b : then source-file ~/.tmux.conf.

My Actual Workflow

Starting my day:

1
2
# Attach to my main work session
tmux attach -t work

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:

1
2
3
4
5
# Detach from work
Ctrl-b d

# Start or attach to project session
tmux attach -t sideproject

Context switch in 2 seconds.

SSH-ing to a server:

1
2
ssh myserver
tmux attach

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Terminal 1: Create the main session
tmux new -s work

# Terminal 2: Create a new session grouped with 'work'
tmux new -t work -s work-view2

# Terminal 3: Another grouped session
tmux new -t work -s work-view3

# Or use the short form (tmux auto-generates unique names)
tmux new -t work

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:

1
2
3
4
5
6
tmux ls

# You'll see something like:
# work: 5 windows (created Mon Nov 11 10:00:00 2025)
# work-view2: 5 windows (created Mon Nov 11 10:01:00 2025) (group work)
# work-view3: 5 windows (created Mon Nov 11 10:02:00 2025) (group work)

The (group work) indicates they share the same windows.

What NOT to do:

1
2
# ❌ This causes mirroring (all terminals show the same window)
tmux attach -t work  # Don't use this in multiple terminals

Bonus alias (add to ~/.zshrc or ~/.bashrc):

1
2
3
4
alias tmux-join='tmux new-session -t'

# Usage:
# tmux-join work

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 WantKey
Detach from sessionCtrl-b d
New windowCtrl-b c
Next/prev windowCtrl-b n/p
Copy mode (scroll)Ctrl-b [
List all commandsCtrl-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


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.

comments powered by Disqus

© 2025 Santosh Manoharan