The First Cry of Atom Today is the first day of the rest of my life.

Clipboard on MacOSX with tmux

With default tmux, you may have some trouble copying text on clipboard. Drag with option key enables you to copy selected text to clipboard. But the number of keys you have to touch when you select has been increased. This is completely annoying. By using reattach-to-user-namespace, you can copy any text from copy mode of tmux to mac clipboard. Below is the process.

First you have to install reattach-to-user-namespace. If you have Homebrew, it is easy.

$ brew install reattach-to-user-namespace

Then write your tmux.conf below.

# Use vim keybindings in copy mode
setw -g mode-keys vi

# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"

My key binding is here. I use Space key as begin-selection, and Enter key as copy-pipe`. Of course, if can change any keys as you like.


tmux Copy & Paste on OS X: A Better Future