how to copy and paste between a tmux buffer and the X clipboard


tmux does not provide a native way to copy and paste between its buffers and other applications. Here are two lines to add to tmux.conf that provide these missing features. Note that xclip must be installed for this to work.

# move x clipboard into tmux paste buffer
bind C-p run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer"
# move tmux copy buffer into x clipboard
bind C-y run "tmux show-buffer | xclip -i"

How you access the data from the X clipboard will depend on your set-up. Commonly, in vim you use "*p, and elsewhere, clicking the middle mouse button usually works effectively.