tmux
tmux on Mac: Homebrew, iTerm2, and the clipboard setup
Install tmux on macOS with Homebrew, fix pbcopy clipboard integration, and decide whether iTerm2's tmux -CC control mode is worth using for your setup.
brew install tmux is the whole installation. What actually takes setup on macOS is the
clipboard โ copying inside tmux doesn't reach pbcopy by default โ and deciding whether to run
tmux the normal way inside iTerm2, or hand control of windows over to iTerm2 with -CC, which
is a genuinely different mode with real tradeoffs, not just a nicer skin.
Installing
brew install tmuxHomebrew always builds current upstream, so version lag โ the thing that matters on Debian or
RHEL โ isn't a concern here. tmux -V after installing should print whatever's current.
The clipboard: pbcopy and reattach-to-user-namespace
Older guides โ and some still-circulating dotfiles โ wrap every clipboard command in
reattach-to-user-namespace, a small tool that existed because Mac OS X 10.5 changed how
daemonized processes relate to the pasteboard service, and tmux's server process lost access to
it as a side effect. tmux 2.6 absorbed that fix directly, so on a current Homebrew tmux you
generally don't need the wrapper โ a plain pbcopy binding works:
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "pbcopy"If you hit a setup where pbcopy from inside tmux silently does nothing โ it does still happen
on some configurations โ reattach-to-user-namespace is still available via brew install reattach-to-user-namespace as a fallback, wrapping the same binding:
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"Try the plain version first. Reach for the wrapper only if copy genuinely isn't working, not as
a precaution. If you're on Apple Silicon, note that brew install reattach-to-user-namespace
installs under /opt/homebrew rather than the old Intel /usr/local, so a binding copied from
an older dotfiles repo that hardcodes /usr/local/bin/reattach-to-user-namespace will fail
silently โ call the command by name and let PATH resolve it instead.
Two more options worth setting alongside it:
set -g set-clipboard on
setw -g mode-keys viset-clipboard on lets tmux talk to the system clipboard via OSC 52 as well, which matters if
you're inside an SSH session and want copy-mode selections to reach your local Mac's clipboard,
not just the remote one.
Terminal.app vs iTerm2
| Terminal.app | iTerm2 | |
|---|---|---|
| True color (24-bit) | Not supported โ falls back to nearest 256-color match | Supported, on by default |
| tmux control mode (-CC) | Not supported | Supported |
| Mouse reporting | Basic support | Full support, more configurable |
| Cost | Free, built in | Free, separate download |
Terminal.app is fine for a plain tmux session with 256 colors and works everywhere with zero setup. The two things it genuinely can't do are true 24-bit color and control mode โ if either matters to you, iTerm2 is the answer, not a Terminal.app workaround.
Truecolor setup
Whichever terminal you use, tmux needs telling that the terminal underneath supports RGB color,
via the Tc or RGB terminal capability:
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"tmux-256color is tmux's own terminfo entry and the current recommendation over the older
screen-256color. Confirm it worked from inside a session:
If $COLORTERM comes back empty inside tmux but prints truecolor outside it, the
terminal-overrides line above is what's missing โ the terminal itself already supports it,
tmux just hasn't been told.
iTerm2 + tmux control mode (-CC)
-CC is a different way of running tmux entirely: instead of drawing a text-mode UI inside a
single terminal window, tmux sends structured data to iTerm2 and iTerm2 renders each tmux
window as a native tab, with native scrollback, search, and copy/paste.
tmux -CC attach -t work| Good for | Bad for |
|---|---|
| Persistent remote sessions you reattach to constantly from one Mac | Attaching from Linux or any non-iTerm2 client โ control mode is iTerm2-only |
| Wanting native macOS scrollback and search instead of tmux's copy mode | Sharing a session with a teammate on plain tmux โ behavior differs enough to confuse them |
| Sessions with modest scrollback history | Sessions with `history-limit` set very high โ reattaching re-syncs all of it and can lag noticeably |
Control mode is worth using if you're on one Mac, reattaching to the same session constantly, and want it to feel like native tabs rather than a terminal-in-a-terminal. It's the wrong choice if you ever attach from somewhere other than iTerm2 on that one machine, or if someone else needs to attach to the same session with plain tmux โ they'll see a session that behaves subtly differently than what you're describing to them.
Option as Meta
By default, macOS terminals don't send an Escape sequence when you press Option โ so Option-b / Option-f (word-back, word-forward in readline, and common in vim and tmux copy-mode bindings) do nothing useful inside a shell. Both terminals have a setting to fix it:
| Terminal | Setting |
|---|---|
| iTerm2 | Preferences โ Profiles โ Keys โ "Left/Right Option Key Acts as: +Esc" |
| Terminal.app | Preferences โ Profiles โ Keyboard โ "Use Option as Meta key" |
This isn't a tmux setting โ it's the terminal emulator deciding what escape sequence Option sends โ but it's squarely a "why doesn't Option-arrow work in my shell inside tmux" question, so it belongs here.
Checking a session from off your Mac
None of the above changes the tmux commands themselves โ see tmux commands
for the full reference. It also doesn't change if you need to check on a session from somewhere
that isn't your Mac โ your phone, someone else's machine. The normal answer is SSH back in and
tmux attach, covered in tmux attach session. If you'd rather get pushed a
notification the moment a long job finishes instead of remembering to reattach, that's what
mtmux does โ npm i -g mtmux on the Mac running the session, and it serves that same tmux to a
browser with a notification when a pane goes quiet.
Do I still need reattach-to-user-namespace on macOS?
Usually not. tmux 2.6 built in the fix it provided, so a plain pbcopy binding works on current
Homebrew tmux. Keep the wrapper as a fallback only if pbcopy genuinely isn't reaching the
clipboard from inside tmux.
Does Terminal.app support tmux truecolor?
No โ Terminal.app tops out below full 24-bit color and falls back to the nearest 256-color match. iTerm2 supports true color and has it on by default.
What is tmux -CC in iTerm2?
Control mode: instead of a text-mode UI, tmux hands window and pane data to iTerm2, which renders each tmux window as a native tab with native scrollback and copy/paste. It only works from iTerm2, and reattaching re-syncs scrollback, which can lag with a large history-limit.
Why doesn't Option-arrow move by word in my Mac terminal?
By default, macOS terminals don't send an Escape sequence for Option. Enable "Option as Meta" in Terminal.app's Keyboard preferences, or "+Esc" in iTerm2's Keys preferences.
How do I install tmux on a Mac without Homebrew?
Building from source is the alternative โ tmux depends only on libevent and ncurses, both already present or installable via Xcode Command Line Tools. Homebrew is easier and keeps you on the current version without manual rebuilds.
Put this to work โ mtmux attaches to the tmux server you already run.