I am running the latest version of tmux (from the git repository) and xclip (0.12), and I would like to be able to use Emacs-like keyboard bindings to move around the text in
copy-mode, copy (
M-w) selections to the clipboard, and paste (
C-y) from/to the copy buffer to the clipboard.
So far I have been able to paste text with
C-y, and move around in
copy-mode with Emacs-like keyboard bindings, but I am still unable to copy text from a tmux buffer (e.g. in
I found this thread for copying the entire buffer to the clipboard (and viceversa), but it does not seem to be working for me.
Also, in the
tmux-users mail list I was told that recent versions of tmux (only in the git repo) provide a command called
copy-pipe. The man page says the following about this command:
One command in accepts an argument, copy-pipe, which copies the selection and pipes it to a command. For example the following will bind ‘C-q’ to copy the selection into /tmp as well as the paste buffer:
bind-key -temacs-copy C-q copy-pipe "cat >/tmp/out"
It looks like
copy-pipe is meant to be used in part to pipe the selection to another command. There also seem to be some typos in this description and in the command (what is
Either way, what I would like to do is:
- Enter copy mode
- Move to the text I want to copy using Emacs navigation commands (i.e.
C-eetc. to move the cursor). No prefix for any of these.
- Copy the selected text into the clipboard with:
M-w(no prefix either)
- I would like to be able to type
C-y(without having to enter
copy-mode) to paste text in the terminal (no prefix either)
I have tried the following for copying without luck:
bind-key -n M-w run "tmux save-buffer - | xclip -i -selection clipboard"
However, pasting works great:
bind-key -n C-y run "xclip -o | tmux load-buffer - ; tmux paste-buffer"
The odd thing is that I know that the "
xclip -i -selection clipboard" part of the copy command above works well, since I can copy things to the clipboard in the command line, e.g.:
echo "Hello world. How are you?" | xclip -i -selection clipboard
With all this, how can I copy a selection from copy mode to the clipboard?