11
11

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 5 years have passed since last update.

Mac (ローカル)とLinux (リモート)とtmuxでクリップボードを共有

Last updated at Posted at 2016-06-03

xselを準備する

xselの動作確認を行う

  • リモートで環境変数 DISPLAY が空でない事を確認
  • ローカルでなんかをコピーし、リモートで xsel を実行
  • リモートで echo $HOME | xsel -bi を実行、ローカルでペーストを実行

既に tmux を起動済の場合 DISPLAY が空の事があるので、その時は手動で設定。

export DISPLAY=localhost:##.#

tmuxを設定する

以下の設定を $HOME/.tmux.conf に追加。

# `tmux` のコピペとクリップボードの連携
# Linux with xsel
if "which xsel" "bind-key -t vi-copy y     copy-pipe 'xsel -bi'"
if "which xsel" "bind-key -t vi-copy Enter copy-pipe 'xsel -bi'"
if "which xsel" "bind-key ] run 'tmux set-buffer -- \"$(xsel -bo)\"; tmux paste-buffer'"
# Mac
if "which pbcopy"  "bind-key -t vi-copy y     copy-pipe 'pbcopy'"
if "which pbcopy"  "bind-key -t vi-copy Enter copy-pipe 'pbcopy'"
if "which pbpaste" "bind-key ] run 'tmux set-buffer -- \"$(pbpaste)\"; tmux paste-buffer'"

最後に source-file $HOME/.tmux.conf で設定ファイルを再読込。

リモートの Neovim でも共有する

この記事を読んで設定ファイルに以下を追加した。

set clipboard+=unnamedplus
11
11
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
11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?