Skip to content

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.

Nadia Okonkwo6 min read

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 tmux

Homebrew 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:

~/.tmux.conf
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:

~/.tmux.conf
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:

~/.tmux.conf
set -g set-clipboard on
setw -g mode-keys vi

set-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.appiTerm2
True color (24-bit)Not supported โ€” falls back to nearest 256-color matchSupported, on by default
tmux control mode (-CC)Not supportedSupported
Mouse reportingBasic supportFull support, more configurable
CostFree, built inFree, 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:

~/.tmux.conf
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:

~ โ€” checking truecolor
[object Object]

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 forBad for
Persistent remote sessions you reattach to constantly from one MacAttaching from Linux or any non-iTerm2 client โ€” control mode is iTerm2-only
Wanting native macOS scrollback and search instead of tmux's copy modeSharing a session with a teammate on plain tmux โ€” behavior differs enough to confuse them
Sessions with modest scrollback historySessions 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:

TerminalSetting
iTerm2Preferences โ†’ Profiles โ†’ Keys โ†’ "Left/Right Option Key Acts as: +Esc"
Terminal.appPreferences โ†’ 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.

Related reading

tmux

tmux ssh: fixing broken pipe and dropped sessions

tmux over SSH keeps a job running through a dropped connection. The pattern is ssh host -t 'tmux attach || tmux new', plus keepalives for broken pipe.

Ivo Hart7 min read

tmux

tmux plugins: TPM, and the five worth installing

TPM installs tmux plugins via prefix + I; the real shortlist is tmux-resurrect, tmux-continuum, tmux-sensible, vim-tmux-navigator and tmux-yank.

Ivo Hart6 min read