|
|
||
|---|---|---|
| scripts | ||
| video | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| .travis.yml | ||
| CHANGELOG.md | ||
| citest | ||
| LICENSE.md | ||
| README.md | ||
| vagrant_provisioning.sh | ||
| Vagrantfile | ||
| yank.tmux | ||
tmux-yank
Copy to the system clipboard in tmux.
Supports:
- Linux
- macOS
- Cygwin
- Windows Subsystem for Linux (WSL)
Installing
Via TPM (recommended)
The easiest way to install tmux-yank is via the Tmux Plugin
Manager.
-
Add plugin to the list of TPM plugins in
.tmux.conf:set -g @plugin 'tmux-plugins/tmux-yank' -
Use prefix–I install
tmux-yank. You should now be able totmux-yankimmediately. -
When you want to update
tmux-yankuse prefix–U.
Manual Installation
-
Clone the repository
$ git clone https://github.com/tmux-plugins/tmux-yank ~/clone/path -
Add this line to the bottom of
.tmux.confrun-shell ~/clone/path/yank.tmux -
Reload the
tmuxenvironment# 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
Note: Beginning with OSX Yosemite (10.10), pbcopy is reported to work
correctly with tmux without reattach-to-user-namespace.
If you have tmux 1.5 or newer and are using
iTerm2 version 3 or newer then the y
in copy-mode and mouse selection will work without tmux-yank.
To enable this:
-
Go into iTerm2's preferences.
-
Go to the "General" tab.
-
Check "Applications in terminal may access clipboard"
-
In
tmux, ensureset-clipboardis turned on:$ tmux show-options -g -s set-clipboard set-clipboard on
HomeBrew (recommended)
$ brew install reattach-to-user-namespace
MacPorts
$ sudo port install tmux-pasteboard
Linux
xsel(recommended) orxclip.
If you have tmux 1.5 or newer and are using xterm, the y in
copy-mode and mouse selection will work without tmux-yank. See the
tmux(1) man page entry for the set-clipboard option.
Debian & Ubuntu
$ sudo apt-get install xsel # or xclip
RedHat & CentOS
$ sudo yum install xsel # or xclip
Cygwin
- (optional)
putclipwhich is part of thecygutils-extrapackage.
Windows Subsystem for Linux (WSL)
clip.exeis shipped with Windows Subsystem for Linux.
Configuration
Key bindings
-
Normal Mode
-
prefix–y — copies text from the command line to the clipboard.
Works with all popular shells/repls. Tested with:
-
prefix–Y — 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
Note: The screen-cast uses Control–y 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.
