Yanks to system clipboard.
Go to file
Bruno Sutic 41f060e087
v2.0.0
2014-12-06 23:53:50 +01:00
scripts Change "put selection" key binding to Y 2014-12-06 23:40:37 +01:00
video Update video/README.md 2014-07-31 11:47:57 +02:00
.gitignore Add gitignore 2014-08-04 23:03:14 +02:00
CHANGELOG.md v2.0.0 2014-12-06 23:53:50 +01:00
LICENSE.md First commit 2014-06-24 11:39:47 +02:00
README.md Change "put selection" key binding to Y 2014-12-06 23:40:37 +01:00
vagrant_provisioning.sh Add Vagrant config for testing on linux 2014-08-04 23:04:02 +02:00
Vagrantfile Add Vagrant config for testing on linux 2014-08-04 23:04:02 +02:00
yank.tmux First check for pbcopy, then for xclip 2014-09-04 20:08:02 +02:00

Tmux Yank

Enables copying to system clipboard in Tmux. Works on Linux and OS X.

Screencast

screencast screenshot

Note: screencast shows using the "put selection" feature with Ctrl-y key binding in copy mode. In v2.0.0 this key binding was changed to Y (shift-y).

Key bindings

  • prefix + y - copies text from the command line to clipboard.
    Works with all popular shells/repls. Tested with:
    • shells: bash, zsh (with bindkey -e), tcsh
    • repls: irb, pry, node, psql, python, php -a, coffee
    • remote shells: ssh, mosh
    • vim/neovim command line (requires vim-husk or vim-rsi plugin)

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

OS X requirements

Linux requirements

  • xclip command
    You most likely already have xclip, but if not:
    • Debian / Ubuntu: $ sudo apt-get install xclip
    • Red hat / CentOS: $ yum install xclip

Copy command

OS X

Copying to clipboard is done using pbcopy.

Linux

Copying to clipboard is done using xclip -selection c command by default.

If copying is different on your system, and you need the command to be i.e. xclip -selection normal, here's how to customize:

# in .tmux.conf
set -g @yank_selection "primary"

Notes

Mouse Support

When making a selection using tmux mode-mouse on or mode-mouse copy-mode, you cannot rely on the default 'release mouse after selection to copy' behavior. Instead, press y before releasing mouse.

Add plugin to the list of TPM plugins in .tmux.conf:

set -g @tpm_plugins "          \
  tmux-plugins/tpm             \
  tmux-plugins/tmux-yank       \
"

Hit prefix + I to fetch the plugin and source it. You should now be able to use the plugin.

Manual Installation

Clone the repo:

$ git clone https://github.com/tmux-plugins/tmux-yank ~/clone/path

Add this line to the bottom of .tmux.conf:

run-shell ~/clone/path/yank.tmux

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 yank works well with tmux copycat and tmux-open plugins.

License

MIT