tmux and macOS Clipboard

Viewed 3505

Is there a reliable way to make tmux 2.5 to work with macOS clipboard?

After upgrading to 2.5 everything went downhill. I have tried every solution I have found and nothing works. Could anybody please provide me with a working sample of tmux.conf that will make it work?

I can copy from neovim inside tmux just fine. I can't copy the text using tmux itself.

Here is what I have in .tmux.conf:

setw -g mode-keys vi
bind-key -T copy-mode-vi 'v' begin-selection
bind-key -T copy-mode-vi 'y' copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" \; display-message "copied to system clipboard"

These are the errors that appear every time the session is started:

.tmux.conf:95: unknown command: begin-selection                
.tmux.conf:96: unknown command: copy-pipe-and-cancel

I have tried the following:

set-window-option -g mode-keys vi
bind-key -Tcopy-mode-vi 'v' send -X begin-selection
bind-key -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel pbcopy

I have also tried:

bind-key -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel

Nothing.

3 Answers

I made it work with tmux 2.6 like so:

Removed any references of reattach-to-user-namespace and now I have this in my .tmux.conf:

set-window-option -g mode-keys vi
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"

Had a problem similar to yours. Try reinstalling reattach-to-user-namespace

brew uninstall --force reattach-to-user-namespace
brew install reattach-to-user-namespace --with-wrap-pbcopy-and-pbpaste

the following works for me

set-window-option -g mode-keys vi
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
Related