LoginSignup
1
0

More than 3 years have passed since last update.

viモードのtmuxでwin32yankとpbcopyを使う

Last updated at Posted at 2020-01-20

一つのtmux.confファイルでWSL用ではwin32yank.exeを使うよう、Macではpbcopyを使うようにしたかったのでif-shellを使って環境ごとにクリップボード共有ツールを変えるようにしました。

tmux.confファイル全体はこちら
https://github.com/tMinamii/dotfiles/blob/master/tmux/tmux.conf

tmux.conf
setw -g mode-keys vi
unbind -T copy-mode-vi Enter
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

## for WSL2
if-shell -b 'test "$(uname -a | grep microsoft)" != ""' \
  'bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "cat | win32yank.exe -i"; \
   bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "cat | win32yank.exe -i"; \
   bind-key C-p run-shell "win32yank -o | tmux load-buffer - && tmux paste-buffer"'

## for Mac
if-shell -b 'test "$(uname -a | grep Darwin)" != ""' \
  'bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"; \
   bind-key -T copy-mode-vi y     send-keys -X copy-pipe-and-cancel "pbcopy"; \
   bind-key C-p run-shell "pbpaste | tmux load-buffer - && tmux paste-buffer"'
1
0
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
1
0