LoginSignup
40
38

More than 5 years have passed since last update.

tmuxとosxのクリップボードを共用する

Posted at

reattach-to-user-namespaceをインストールする

$ brew install reattach-to-user-namespace

tmux-pbcopy を作成

via. http://koseki.hatenablog.com/entries/2011/08/16

tmux-pbcopy
#! /bin/sh

tmux save-buffer /tmp/.tmux_to_pbcopy
cat /tmp/.tmux_to_pbcopy | pbcopy

# 下記は表示だけなのでなくてもOK
HEAD=`head -1 /tmp/.tmux_to_pbcopy`
TAIL=`tail -1 /tmp/.tmux_to_pbcopy`
tmux display-message "Copy:  $HEAD  -  $TAIL"

上記のスクリプトをpathが通ったところに置く

.tmux.confに下記を追記

set-option -g default-command "reattach-to-user-namespace -l $SHELL"
bind C-q run-shell 'reattach-to-user-namespace tmux-pbcopy'

tmuxからmacのクリップボードにコピーする場合

C-t(prefix) [ でcopyモードへ。
Emacs keybindにしてあるのでC-spaceで選択開始、C-wでtmux のクリップボードに保存されるので、macのそれにコピーしてあげる必要がある。これは前述の通り、C-t C-qで実行できる。

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

$ pbpaste

でOK。

40
38
0

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
40
38