0
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

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

一つの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"'
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?