Go back to the main page

Copy and paste from tmux to OSX clipboard

This article is over 2 years old. Proceed with caution.

Regards ♨ – Minimul

 
  1. tmux kill-session (important: tmux must be restarted)
  2. brew install reattach-to-user-namespace
  3. Edit ~/.tmux.conf
# Important! For bash shell : use "-l zsh" for z shell
set -g default-command "reattach-to-user-namespace -l bash"
bind-key y run-shell "tmux save-buffer - | reattach-to-user-namespace pbcopy"

Then.

  1. tmux
  2. Open a file in a tmux window e.g. less /var/log/apache/error.log
  3. Hit '{prefix} ['
  4. Hit 'spacebar'
  5. Select text block with arrow keys or vim/emacs movement bindings
  6. Hit 'Enter'
  7. Hit '{tmux-prefix} y'
  8. Check your OSX clipboard the paste should be there.

Alternate method

One work around is to open the file you want to copy using MacVim from your vim console session via :!mvim %. From MacVim you get a nice copy to clipboard experience.

Comment on this article?