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
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.
(setq x-select-enable-clipboard t
# COPY & PASTE
# 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"