Enables copying to system clipboard in Tmux.
Tested and working on Linux, OSX and Cygwin.
Note: screencast shows using the "put selection" feature with
binding in copy mode. In
v2.0.0 this key binding was changed to
prefix + y- copies text from the command line to clipboard.
Works with all popular shells/repls. Tested with:
prefix + Y(shift-y) - copy pane current working directory to clipboard.
copy mode bindings:
y- copy selection to system clipboard
Y(shift-y) - "put" selection - equivalent to copying a selection, and pasting it to the command line
Alt-y- performs both of the above: copy to system clipboard and put to command line (deprecated, not useful)
OS X requirements
Install with brew
$ brew install reattach-to-user-namespaceor macports
$ sudo port install tmux-pasteboard.
Note: Beginning with OSX Yosemite (10.10),
pbcopyis reported to work correctly with
tmux, so we believe
reattach-to-user-namespaceis not needed anymore. Please install it in case the plugin doesn't work for you.
You most likely already have one of them, but if not:
- Debian / Ubuntu:
$ sudo apt-get install xclipor
$ sudo apt-get install xsel
- Red hat / CentOS:
$ yum install xclipor
$ yum install xsel
- Debian / Ubuntu:
Get the command by installing
cygutils-extrapackage with Cygwin's
When making a selection using tmux
mode-mouse on or
you cannot rely on the default 'release mouse after selection to copy' behavior.
y before releasing mouse.
Shell vi mode compatibility
# in .tmux.conf set -g @shell_mode 'vi'
Copying to clipboard is done using
xclip -selection clipboard or
xsel --clipboard command by default.
If copying is different on your system, and you need the command to be i.e.
xclip -selection primary or
xsel -i --primary, here's how to customize:
# in .tmux.conf set -g @yank_selection 'primary'
Use full names as option ('primary', 'secondary', 'clipboard')
Tmux Plugin Manager (recommended)Installation with
Add plugin to the list of TPM plugins in
set -g @plugin 'tmux-plugins/tmux-yank'
prefix + I to fetch the plugin and source it. You should now be able to
use the plugin.
Clone the repo:
$ git clone https://github.com/tmux-plugins/tmux-yank ~/clone/path
Add this line to the bottom of
Reload TMUX environment:
# type this in terminal $ tmux source-file ~/.tmux.conf
You should now be able to use the plugin.
Other Tmux goodies
- tmux-copycat - a plugin for regex searches in tmux and fast match selection
- tmux-open - a plugin for quickly opening highlighted file or a url
- tmux-continuum - automatic restoring and continuous saving of tmux env
You might want to follow @brunosutic on twitter if you want to hear about new tmux plugins or feature updates.