I have the following code in my init.el

(xclip-mode +1)
  x-select-enable-clipboard t
  x-select-enable-primary t
  x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)
  x-stretch-cursor t)

In a regular terminal, copy and paste works seamlessly. However in tmux the kill-ring is not synchronized with my regular clipboard, and yank does not yank from the clipboard. How can I fix this?

  • Is your tmux copy buffer, synchronized with your clipboard?
    – Nsukami _
    Commented Jan 9, 2015 at 1:21
  • Yes, but emacs does not modify the tmux copy buffer. In addition, the synchronization is done on a keybinding based method and is not general.
    – PythonNut
    Commented Jan 9, 2015 at 3:29
  • I'm not really sure to have clearly understood your problem, but I think, the best approach would be to not modify the tmux copy buffer from Emacs. Instead, you should only modify the clipboard, then tmux should be able to grab what's inside the clipboard.
    – Nsukami _
    Commented Jan 10, 2015 at 1:34

1 Answer 1


You need to customize the .tmux.conf too in addition to the below customization in emacs.

With the below setup here are few scenarios of how copy-pasting can work between emacs and tmux:

  • Copy/cut from emacs and paste in shell command line in tmux: Do M-w or C-w in emacs and TMUX_PREFIX C-y in tmux.
  • Copy from tmux and paste in emacs: Do TMUX_PREFIX C-w in tmux and C-y in emacs.

emacs setup

(setq x-select-enable-clipboard t 
      x-select-enable-primary t)

tmux setup


# Copy tmux buffer to X clipboard
# run -b runs a shell command in background
# bind C-w run -b "tmux show-buffer | xclip -selection clipboard -i"
bind C-w run -b "tmux show-buffer | xclip -i"

# Paste from X clipboard into tmux; also replace newline characters with
# space characters when pasting
bind C-y run -b "exec </dev/null; xclip -o | awk 1 ORS=' ' | tmux load-buffer - ; tmux paste-buffer"
# Same as `C-y' binding except that the newline chars are not replaced with space
bind Y run -b "exec </dev/null; xclip -o | tmux load-buffer - ; tmux paste-buffer"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.