Yanks to system clipboard.
Go to file
2017-05-04 23:45:24 -04:00
scripts Merge pull request #79 from lukewang1024/feature/WSL-support 2017-05-04 11:44:15 -04:00
video Update video/README.md 2014-07-31 11:47:57 +02:00
.editorconfig Reformatted CHANGELOG 2017-05-04 22:07:48 -04:00
.gitattributes Reformatted CHANGELOG 2017-05-04 22:07:48 -04:00
.gitignore Add gitignore 2014-08-04 23:03:14 +02:00
CHANGELOG.md changelog: use http://keepachangelog.com/ format 2017-05-04 22:40:05 -04:00
LICENSE.md readme: cleanup and reformatting. 2017-05-04 23:45:24 -04:00
README.md readme: cleanup and reformatting. 2017-05-04 23:45:24 -04:00
vagrant_provisioning.sh Update vagrant provisioning script 2015-10-12 14:10:35 +02:00
Vagrantfile Add Vagrant config for testing on linux 2014-08-04 23:04:02 +02:00
yank.tmux Fix <= 2.3 support 2017-05-04 11:41:32 -04:00

tmux Yank

Copy to the system clipboard in tmux.

Supports:

  • Linux
  • macOS
  • Cygwin
  • Windows Subsystem for Linux (WSL)

Installing

The easiest way to install tmux-yank is via the Tmux Plugin Manager.

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

    set -g @plugin 'tmux-plugins/tmux-yank'
    
  2. Use prefixI install tmux-yank. You should now be able to tmux-yank immediately.

  3. When you want to update tmux-yank use prefixU.

Manual Installation

  1. Clone the repository

    $ git clone https://github.com/tmux-plugins/tmux-yank ~/clone/path
    
  2. Add this line to the bottom of .tmux.conf

    run-shell ~/clone/path/yank.tmux
    
  3. Reload the tmux environment

    # type this inside tmux
    $ tmux source-file ~/.tmux.conf
    

You should now be able to use tmux-yank immediately.

Requirements

In order for tmux-yank to work, there must be a program that store data in the system clipboard.

macOS

$ brew install reattach-to-user-namespace

MacPorts

$ sudo port install tmux-pasteboard

Note: Beginning with OSX Yosemite (10.10), pbcopy is reported to work correctly with tmux without reattach-to-user-namespace.

Linux

  • xsel (recommended) or xclip.

Debian & Ubuntu

$ sudo apt-get install xsel # or xclip

RedHat & CentOS

$ sudo yum install xsel # or xclip

Cygwin

  • (optional) putclip which is part of the cygutils-extra package.

Windows Subsystem for Linux (WSL)

  • clip.exe is shipped with Windows Subsystem for Linux.

Configuration

Key bindings

  • Normal Mode

    • prefixy — copies text from the command line to the 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)
    • prefixY — copy the current pane's current working directory to the clipboard.

  • Copy Mode

    • y — copy selection to system clipboard.
    • Y (shift-y) — "put" selection. Equivalent to copying a selection, and pasting it to the command line.

Linux Clipboards

Linux has several cut-and-paste clipboards: primary, secondary, and clipboard.

You can change this by setting @yank_selection:

# ~/.tmux.conf

set -g @yank_selection 'primary' # or 'secondary' or 'clipboard'

Mouse Support

When making a selection using tmux with 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.

vi mode support

If using tmux 2.3 or older and using vi keys then you'll have add the following configuration setting:

# ~/.tmux.conf

set -g @shell_mode 'vi'

This isn't needed with tmux 2.4 or newer.

Screen-cast

screencast
screenshot

Note: The screen-cast uses Controly for "put selection". Use Y in v2.0.0 and later.

Other tmux plugins

  • tmux-copycat - a plugin for regular expression 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 environment.

License

MIT