How to Copy and Paste with Tmux on Ubuntu
1. Install xclip
$ sudo apt-get install xclip
2. Configure Tmux
Open up your Tmux configuration (typically at ~/.tmux.conf) and append:
tmux version >= 1.8
bind -t vi-copy y copy-pipe "xclip -sel clip -i"
Now when you copy some text, it will automatically be copied to OS clipboard.
tmux version < 1.8
# copy & paste between tmux and x clipboard
bind C-p run-shell "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer"
bind C-y run-shell "tmux show-buffer | xclip -sel clip -i"
Now, when you press <Control> Ctrl-p
, it will put the content of x clipboard into Tmux buffer and paste it.
<Control> Ctrl-y
will put Tmux top buffer content into x clipboard. Thus, a typical workflow will be as follows:
- Enter copy mode
- Select text
- Yank it
- Send it to x clipboard if needed
P.S. Don't forget to restart your tmux server.
Written by Anton Kalyaev
Related protips
2 Responses
Nice. The most irritating thing in tmux solved! Thx
over 1 year ago
·
This didn't quite work for me. It was waiting for an EOF in the command and never completed. I eventually used:
bind -t vi-copy y copy-pipe "xclip"
Source: http://unix.stackexchange.com/questions/15715/getting-tmux-to-copy-a-buffer-to-the-clipboard/16405
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Tmux
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#