Coder Social home page Coder Social logo

esteban-rocha / tmux-yank Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tmux-plugins/tmux-yank

0.0 1.0 0.0 140 KB

Tmux plugin for copying to system clipboard. Works on OSX, Linux and Cygwin.

Home Page: https://tmux-plugins.github.io/tmux-yank/

License: MIT License

Shell 100.00%

tmux-yank's Introduction

Build Status GitHub release GitHub issues

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.

  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

Note: Some versions of macOS (aka OS X) have been reported to work without reattach-to-user-namespace. It doesn't hurt to have it installed.

  • OS X 10.8: Mountain Lion – required
  • OS X 10.9: Mavericks – required
  • OS X 10.10: Yosemite – not required
  • OS X 10.11: El Capitan – not required
  • macOS 10.12: Sierra – required

The easiest way to use reattach-to-user-namespace with tmux is use to use the tmux-sensible plugin.

To use it manually, use:

# ~/.tmux.conf
set-option -g default-command "reattach-to-user-namespace -l $SHELL"

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:

  1. Go into iTerm2's preferences.

  2. Go to the "General" tab.

  3. Check "Applications in terminal may access clipboard"

  4. In tmux, ensure set-clipboard is 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) or xclip.

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) 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.

Default and Preferred Clipboard Programs

tmux-yank does its best to detect a reasonable choice for a clipboard program on your OS.

If tmux-yank can't detect a known clipboard program then it uses the @custom_copy_command tmux option as your clipboard program if set.

If you need to always override tmux-yank's choice for a clipboard program, then you can set @override_copy_command to force tmux-yank to use whatever you want.

Note that both programs must accept STDIN for the text to be copied.

An example of setting @override_copy_command:

# ~/.tmux.conf

set -g @custom_copy_command 'my-clipboard-copy --some-arg'
# or
set -g @override_copy_command 'my-clipboard-copy --some-arg'

Linux Clipboards

Linux has several cut-and-paste clipboards: primary, secondary, and clipboard (default in tmux-yank is 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

tmux-yank's People

Contributors

docwhat avatar romainbossart avatar edi9999 avatar bruno- avatar calvinchengx avatar janko avatar lukewang1024 avatar maximbaz avatar qstrahl avatar sencer avatar duffytilleman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.