LoginSignup
7

More than 3 years have passed since last update.

posted at

updated at

tmuxからクリップボードにコピーする

環境

Ubuntu 16.04.2 LTS
tmux 2.1
xsel version 1.2.0

※現行バージョンのtmuxはバージョンが2.9となります。この記事の情報は古いです。
※※令和版を書きました。→https://qiita.com/purutane/items/1d1dc4818013bbbaead4

設定箇所

下記を~/.tmux.confに追記しました。

~/.tmux.conf
set-window-option -g mode-keys vi

-bind-key -t vi-copy v begin-selection
-bind-key -t vi-copy C-v rectangle-toggle
-bind-key -t vi-copy y copy-pipe "xsel -bi"
-bind-key -t vi-copy Enter copy-pipe "xsel -bi"

※もともと"v"にはrectangle-toggleがバインドされているために、"C-v"にバインドを移動させています。

使い方

  1. "<prefix> ["でコピーモードに入る
  2. "v"で選択を開始
  3. "y"もしくは"Enter"で選択を終了(コピー)、その結果がxselにパイプされクリップボードにコピー
  4. ハッピー

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
7