44
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

tmuxからクリップボードにコピーする(令和版)

Last updated at Posted at 2019-06-09

#環境
Arch Linux 2019.06.04
tmux 2.9a
xsel version 1.2.0

※以前の記事は環境が古いため書き直しました。

#設定箇所
下記を~/.tmux.confに追記しました。

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

bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xsel -bi"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xsel -bi"

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

#使い方

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

#おまけ(WSL版)
win32yank.exeはPATHの通っているところに置きましょうね~。

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

bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "cat | win32yank.exe -i"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "cat | win32yank.exe -i"
44
22
2

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
  3. You can use dark theme
What you can do with signing up
44
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?